Learn R Programming

IFC (version 0.2.1)

data_add_regions: Add Region to IFC_data Object

Description

Adds regions to an already existing `IFC_data` object.

Usage

data_add_regions(obj, regions, ...)

Value

an IFC_data object with regions added.

Arguments

obj

an `IFC_data` object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

regions

a list of region(s) to add to obj. Each element of this list will be coerced by buildRegion.

...

Other arguments to be passed.

Details

A warning will be thrown if a provided region is already existing in 'obj'.
In such a case this region will not be added to 'obj'.
If any input population is not well defined and can't be created then an error will occur.

Examples

Run this code
if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  daf <- ExtractFromDAF(fileName = file_daf)
  ## copy 1st region found in daf
  reg <- daf$regions[[1]]
  if(length(reg) != 0) {
    reg_copy <- reg
    ## modify region label and x boundaries
    reg_copy$label <- paste0(reg_copy$label,"_copy")
    reg_copy$x <- reg_copy$x*0.9
    ## create new object with this new region
    dafnew <- data_add_regions(obj = daf, regions = list(reg_copy))
  }
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Run the code above in your browser using DataLab