createLookup | R Documentation |
Extract unique values from one or multiple variables of a GADSdat
object for recoding (e.g. via an Excel spreadsheet).
createLookup(GADSdat, recodeVars, sort_by = NULL, addCols = c("value_new"))
GADSdat |
A |
recodeVars |
Character vector of variable names which should be recoded. |
sort_by |
By which column ( |
addCols |
Character vector of additional column names for recoding purposes. |
If recoding of one or multiple variables is more complex, a lookup table can be created for later application via
applyLookup
or applyLookup_expandVar
. The function allows the extraction of the values
of multiple variables and sorting of these unique values via variable
and/or values
.
If addCols
are specified the lookup table has to be formatted via collapseColumns
,
before it can be applied to recode data.
Returns a data frame in long format with the following variables:
variable |
Variables as specified in |
value |
Unique values of the variables specified in |
value_new |
This is the default for |
# create example GADS
dat <- data.frame(ID = 1:4, var1 = c(NA, "Eng", "Aus", "Aus2"),
var2 = c(NA, "French", "Ger", "Ita"),
stringsAsFactors = FALSE)
gads <- import_DF(dat)
# create Lookup table for recoding
lookup <- createLookup(gads, recodeVars = c("var1", "var2"), sort_by = c("value", "variable"))
# create Lookup table for recoding by multiple recoders
lookup2 <- createLookup(gads, recodeVars = c("var1", "var2"), sort_by = c("value", "variable"),
addCols = c("value_recoder1", "value_recoder2"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.