transform_entityValue() takes a full Rxs project object (as produced by rxs_parseExtractionScripts()) and processes all Rxs trees, looking for entities that match the entityId_regex regular expression (for information about what clustering entities are, see https://sysrevving.com/glossary.html) and passes those to function fun, passing the entity's value as the argument named in entityValue_argName and with funArgs as additional arguments.

transform_entityValue(
  x,
  fun,
  entityValue_argName = "x",
  entityId_regex = NULL,
  newEntityName_prefix = "",
  newEntityName_suffix = "_trfmd",
  funArgs = NULL,
  requiredField_regex = NULL
)

Arguments

x

The full Rxs project object (as produced by rxs_parseExtractionScripts()).

fun

The function to apply.

entityValue_argName

The argument name to pass the entity value as.

entityId_regex

An optional regular expression: if specified, only entity nodes with entity identifiers that match this regular expression will be processed.

newEntityName_prefix, newEntityName_suffix

The prefix and suffix to add to the entity identifier to create the name of the new entity that is created. That entity is added as a sibling of the target entity.

funArgs

Additional arguments, as a names list with each element's name is the argument name and the element itself the content.

requiredField_regex

This functionality has not yet been implemented.

Value

Invisibly, the full Rxs project object. Note that the Rxs trees will be changed in place given data.tree's pass-by-reference logic; so you can discard the result.

Examples

### Load an example Rxs project
data('example_rxsProject_1', package="metabefor");

### Show the sample sizes
metabefor::get_singleValue(
  example_rxsProject_1,
  "sampleSize"
);
#>         sourceId   entityId value
#> 1 qurid_7h50rzpq sampleSize     1
#> 2 qurid_7h50rzmz sampleSize     2

### Double the sample sizes
metabefor::transform_entityValue(
  example_rxsProject_1,
  function(x) {
    return(x * 2);
  },
  entityId_regex = "sampleSize"
);

### Show transformed result

### Show the sample sizes
metabefor::get_singleValue(
  example_rxsProject_1,
  "sampleSize_trfmd"
);
#>         sourceId         entityId value
#> 1 qurid_7h50rzpq sampleSize_trfmd     2
#> 2 qurid_7h50rzmz sampleSize_trfmd     4