View source: R/doRegroupings.R
regroup | R Documentation |
Assign Values to Groups of Values
regroup( x, assignments, ignore.case = NULL, to.factor = FALSE, to.numeric = TRUE )
x |
vector of values |
assignments |
list of assignments of the form \<key\> = \<values\> with
\<values\> being a vector of elements to be looked up in |
ignore.case |
if |
to.factor |
if |
to.numeric |
if |
vector with as many elements as there are elements in x
. The
vector contains \<key\> at positions where the elements in x
appeared
in the vector \<values\> of a \<key\> = \<values\> assignment of
assignments
regroup(c("A", "B", "C", "D"), assignments = list( "AB" = c("A", "B"), "CD" = c("C", "D") )) x <- c("A", "B", "C", "D", "E", "A") assignments <- list( "1" = c("A", "B"), "2" = c("C", "D") ) regroup(x, assignments) # to.factor is ignored... regroup(x, assignments, to.factor = TRUE) # ... unless to.numeric is FALSE! regroup(x, assignments, to.factor = TRUE, to.numeric = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.