In a list of vectors, split vectors to multiple list elements
splitVectors(x, sep = "_", fieldname_regex_alwaysFlatten = NULL)
Arguments
- x
The list of vectors
- sep
The separator to use
- fieldname_regex_alwaysFlatten
A regular expression that, when it
matches a field name, always causes that field's contents to be flattened.
Value
Either a vector, or a list with 'split' vectors
Examples
metabefor::splitVectors(
list(
c(1, 2, 3),
4,
c(5, 6)
)
);
#> <NA> <NA> <NA> <NA> <NA> <NA>
#> 1 2 3 4 5 6
### With list names
metabefor::splitVectors(
list(
a = c(1, 2, 3),
b = 4,
c = c(5, 6)
)
);
#> a_1 a_2 a_3 b c_1 c_2
#> 1 2 3 4 5 6