Learn R Programming

IFC (version 0.2.1)

data_add_features: Add Feature to IFC_data Object

Description

Adds features to an already existing `IFC_data` object.

Usage

data_add_features(obj, features, ...)

Value

an IFC_data object with features added.

Arguments

obj

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

features

a list of features to add to obj. Each element of this list will be coerced by buildFeature.

...

Other arguments to be passed.

Details

A warning will be thrown if a provided feature is already existing in obj.
In such a case this feature will not be added to obj.
If any input feature 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 feature found in daf
  feat_def <- daf$features_def[[1]]
  if(length(feat_def) != 0) {
    feat_def_copy <- feat_def
    ## modify name and value of copied features
    feat_def_copy$name <- "copied_feature"
    feat <- daf$features[, feat_def$name]
    feat_copy <- feat
    feat_copy <- feat_copy * 10
    ## create new object with this new feature
    dafnew <- data_add_features(obj = daf, features = list(c(feat_def_copy, list(val = feat_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