| recode2NA | R Documentation |
NA.Recode multiple values in multiple variables in a GADSdat to NA.
recode2NA(GADSdat, recodeVars = namesGADS(GADSdat), value = "")
GADSdat |
A |
recodeVars |
Character vector of variable names which should be recoded. |
value |
Which values should be recoded to |
If there are value labels given to the specified value, a warning is issued. Number of recodes per variable are reported.
If a data set is imported from .sav, character variables frequently contain empty strings. Especially if parts of the
data are written to .xlsx, this can cause problems (e.g. as look up tables from createLookup),
as most function which write to .xlsx convert empty strings to NAs. recodeString2NA can be
used to recode all empty strings to NA beforehand.
Returns the recoded GADSdat.
# create example GADS
dat <- data.frame(ID = 1:4, var1 = c("", "Eng", "Aus", "Aus2"),
var2 = c("", "French", "Ger", "Ita"),
stringsAsFactors = FALSE)
gads <- import_DF(dat)
# recode empty strings
gads2 <- recode2NA(gads)
# recode numeric value
gads3 <- recode2NA(gads, recodeVars = "ID", value = 1:3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.