View source: R/explicit_guide_factor.R
| explicit_guide.factor | R Documentation |
Coerces factor 'guide' attribute to something more explicit. The attribute 'guide' generally suggests a guide to interpretation of a data item, such as units, formats, codelists, and encodings. The idea here is to replace 'guide' with something explicit in case required downstream. Generally a codelist is expected, but not enforced.
## S3 method for class 'factor'
explicit_guide(
x,
...,
overwrite = getOption("yamlet_explicit_guide_overwrite", TRUE),
simplify = getOption("yamlet_explicit_guide_simplify", TRUE),
expand = getOption("yamlet_expand_codelist", TRUE)
)
x |
factor |
... |
named arguments passed to |
overwrite |
whether to overwrite attributes |
simplify |
whether to remove guide attribute |
expand |
whether to expand empty guide list using sorted unique values. NA likely excluded. |
factor
Other explicit_guide:
explicit_guide(),
explicit_guide.data.frame(),
explicit_guide.dvec(),
explicit_guide.yamlet(),
implicit_guide(),
implicit_guide.data.frame(),
implicit_guide.dvec(),
implicit_guide.factor(),
infer_guide()
library(magrittr)
x <- data.frame(
ID = as_dvec(1),
SEX = factor(1)
)
x %<>% modify(SEX, label = 'sex', guide = list(female = 0, male = 1))
x %>% decorations
x %>% explicit_guide %>% decorations
x %>% explicit_guide(SEX) %>% decorations # limit scope
x %$% SEX %>% explicit_guide
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.