Description Usage Arguments Value Examples
View source: R/run-recode-all.R
Column names in values_tbl
should match names in def_list
1 | def_recode_all(values_tbl, def_list, .default = NULL, .missing = NULL)
|
values_tbl |
A data frame with values stored in a coded format. |
def_list |
A list of definition sets, likely produced by |
.default |
If supplied, all values not otherwise matched will be given this value. If not supplied and if the replacements are the same type as the original values in .x, unmatched values are not changed. If not supplied and if the replacements are not compatible, unmatched values are replaced with NA. .default must be either length 1 or the same length as .x. |
.missing |
If supplied, any missing values in .x will be replaced by this value. Must be either length 1 or the same length as .x. |
A data frame with the same rows and columns as values_tbl
, with columns recoded according to def_recode
1 2 3 4 5 6 7 8 9 10 11 | def_list <- tibble::tibble(variable = c("A", "A", "B", "B", "C"),
value = c(1, 2, 1, 2, 1),
definition = c("cat", "dog", "fred", "george", "lonely")) %>%
def_prep(variable, value, definition, drop_solos = FALSE)
source_data <- tibble::tibble(ID = c("A1", "A2", "A3"),
A = c(1, 1, 2),
B = c(2, 1, 2),
C = c(1, 1, 1))
def_recode_all(source_data, def_list)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.