# NOT RUN {
library(magrittr)
library(dplyr)
file <- system.file(package = 'yamlet', 'extdata','quinidine.csv')
x <- decorate(file)
# modify selected columns
x %<>% modify(title = paste(label, '(', guide, ')'), time)
x %>% select(time, conc) %>% decorations
# modify (almost) all columns
x %<>% modify(title = paste(label, '(', guide, ')'), -Subject)
x %>% select(time, conc) %>% decorations
# use column itself
x %<>% modify(`defined values` = sum(!is.na(.)))
x %>% select(time) %>% decorations
# rename column
x %<>% modify(time, name = label)
names(x)
# warn if assignment fails
# }
# NOT RUN {
\donttest{
x %<>% modify(title = foo, time)
}
# }
# NOT RUN {
# support lists
list(a = 1, b = 1:10, c = letters) %>%
modify(length = length(.), b:c)
x %<>% select(Subject) %>% modify(label = NULL, `defined values` = NULL)
# distinguish data and environment
location <- 'environment'
x %>% modify(where = location) %>% decorations
x %>% modify(where = .env$location) %>% decorations
# }
# NOT RUN {
\donttest{
x%>% modify(where = .data$location) %>% decorations
}
# }
# NOT RUN {
x %>% modify(location = 'attributes', where = location) %>% decorations
x %>% modify(location = 'attributes', where = .data$location) %>% decorations
# }
Run the code above in your browser using DataLab