| recode2NA {eatGADS} | R Documentation |
Recode values to NA.
Description
Recode multiple values in multiple variables in a GADSdat to NA.
Usage
recode2NA(GADSdat, recodeVars = namesGADS(GADSdat), value = "")
Arguments
GADSdat |
A |
recodeVars |
Character vector of variable names which should be recoded. |
value |
Which values should be recoded to |
Details
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.
Value
Returns the recoded GADSdat.
Examples
# 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)
[Package eatGADS version 1.1.0 Index]