View source: R/replace_by_table.R
replace_by_table | R Documentation |
Use a codes table to recode variable. Might be useful for translation of labels, for example.
replace_by_table(
variable = all.data$cntry,
lookup.table = recodes2,
matching.column = "cntry",
replacement.column = "",
save.levels.order = T
)
variable |
Variable to recode. |
lookup.table |
Data frame with (at least) two columns named in line with the following arguments: 'matching.column' and 'replacement.column' |
matching.column |
Character. Lookup table's column of containing (pattern) values simiar to ones in 'variable' |
replacement.column |
Character. Lookup table's column containing substitution values. |
save.levels.order |
Logical. If the level order should follow the matching.column's levels order. |
library(readxl)
codes <- read_excel("countryCodes.xls", 1)
replace_by_table(mydata$var1, codes, "iso2c", "full.country.names")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.