
Last chance! 50% off unlimited learning
Sale ends in
This is the main objective of the variable key system.
keyApply(dframe, key, diagnostic = TRUE, safeNumericToInteger = TRUE,
ignoreCase = TRUE, debug = FALSE)
An R data frame
A variable key object, of class either "key" or "keylong"
Default TRUE: Compare the old and new data frames carefully with the keyDiagnostic function.
Default TRUE: Should we treat values
which appear to be integers as integers? If a column is
numeric, it might be safe to treat it as an integer. In many
csv data sets, the values coded c(1, 2, 3) are really
integers, not floats c(1.0, 2.0, 3.0). See safeInteger
.
Default TRUE. If column name is capitalized differently than name_old in the key, but the two are otherwise identical, then the difference in capitalization will be ignored.
Default FALSE. If TRUE, emit some warnings.
A recoded version of dframe
# NOT RUN {
mydf.key.path <- system.file("extdata", "mydf.key.csv", package = "kutils")
mydf.key <- keyImport(mydf.key.path)
mydf.path <- system.file("extdata", "mydf.csv", package = "kutils")
mydf <- read.csv(mydf.path, stringsAsFactors = FALSE)
mydf2 <- keyApply(mydf, mydf.key)
nls.keylong.path <- system.file("extdata", "natlongsurv.key_long.csv", package = "kutils")
nls.keylong <- keyImport(nls.keylong.path, long = TRUE)
data(natlongsurv)
nls.dat <- keyApply(natlongsurv, nls.keylong)
# }
Run the code above in your browser using DataLab