For example, c('red', 'brown') becomes list(red = 1, brown = 1).

rxsProject_vectorValue_to_valueList(x, entityId, allPossibleValues = NULL)

rxsTreeList_vectorValue_to_valueList(x, entityId, allPossibleValues = NULL)

rxsTree_vectorValue_to_valueList(x, entityId, allPossibleValues = NULL)

vectorValue_to_valueList(
  value,
  allPossibleValues = NULL,
  labels = NULL,
  valueForPresence = 1,
  valueForAbsence = 0
)

Arguments

x

A Rxs tree

entityId

The entity Id

allPossibleValues

A list of all possible values

value

The vector value to convert

labels

Optionally, a named vector with labels to replace the actual values with; names are values, values are labels.

valueForPresence

Value to assign for the elements in the vector

valueForAbsence

Value to assign for the elements in allPossibleValues that do not occur in the vector

Value

The Rxs tree specified in x, invisibly.

The list

Examples

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

### Look at the sample size specified in
### an Rxs tree for a source
example_rxsProject_1$rxsTrees$qurid_7h50rzmz$methods$sample$sampleSize$value;
#> [1] 2

### Set it to a vector
example_rxsProject_1$rxsTrees$qurid_7h50rzmz$methods$sample$sampleSize$value <-
  c(80, 62);

### Convert the values to a value list
rxsTree_vectorValue_to_valueList(
  example_rxsProject_1$rxsTrees$qurid_7h50rzmz,
  "sampleSize"
);

### Verify that this happened
example_rxsProject_1$rxsTrees$qurid_7h50rzmz$methods$sample$sampleSize$value;
#> $`80`
#> [1] 1
#> 
#> $`62`
#> [1] 1
#> 

### Example for one vector
metabefor::vectorValue_to_valueList(
  c('red', 'brown')
);
#> $red
#> [1] 1
#> 
#> $brown
#> [1] 1
#>