# NOT RUN {
file <- system.file(package = 'yamlet', 'extdata','quinidine.csv')
meta <- system.file(package = 'yamlet', 'extdata','quinidine.yaml')
identical(
decorate(file),
decorate(file, meta)
)
identical(
decorate(file, meta = as_yamlet(meta)),
decorate(file, meta = meta)
)
a <- decorate(file)
b <- resolve(decorate(file))
c <- resolve(decorate(
file,
read = read.table,
quote = "",
as.is = FALSE,
sep = ',',
header = TRUE,
na.strings = c('', '\\s', '.','NA'),
strip.white = TRUE,
check.names = FALSE
))
d <- decorate(
file,
read = read.table,
quote = "",
as.is = FALSE,
sep = ',',
header = TRUE,
na.strings = c('', '\\s', '.','NA'),
strip.white = TRUE,
check.names = FALSE
)
# Importantly, b and c are identical with respect to factors
cbind(
`as.is/!resolve` = sapply(a, class), # no factors
`as.is/resolve` = sapply(b, class), # factors made during decoration
`!as.is/resolve` = sapply(c, class), # factors made twice!
`!as.is/!resolve` = sapply(d, class) # factors made during read
)
str(a$Smoke)
str(b$Smoke)
str(c$Smoke)
str(d$Smoke)
levels(c$Creatinine)
levels(d$Creatinine) # level detail retained as 'guide'
# }
Run the code above in your browser using DataLab