View source: R/explicit_guide.R
explicit_guide.data.frame | R Documentation |
Coerces data.frame 'guide' attributes 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.
## S3 method for class 'data.frame'
explicit_guide(
x,
...,
overwrite = getOption("yamlet_explicit_guide_overwrite", TRUE),
simplify = getOption("yamlet_explicit_guide_simplify", TRUE),
expand = getOption("yamlet_expand_codelist", TRUE)
)
x |
data.frame |
... |
named arguments passed to |
overwrite |
passed as TRUE |
simplify |
whether to remove guide attribute |
expand |
whether to expand empty guide list using sorted unique values. NA likely excluded. |
This method pulls the 'decorations' off of the data.frame,
converts to yamlet, applies explicit_guide.yamlet
,
purges 'guide' attributes from the data.frame,
and then re-decorates using overwrite = TRUE
.
data.frame
Other explicit_guide:
explicit_guide()
,
explicit_guide.dvec()
,
explicit_guide.yamlet()
,
implicit_guide()
,
implicit_guide.data.frame()
,
implicit_guide.dvec()
,
infer_guide()
Other dvec:
[.dvec()
,
[<-.dvec()
,
[[.dvec()
,
[[<-.dvec()
,
as.data.frame.dvec()
,
as_dvec()
,
as_dvec.character()
,
as_dvec.complex()
,
as_dvec.dvec()
,
as_dvec.integer()
,
as_dvec.logical()
,
as_dvec.numeric()
,
c.dvec()
,
classified.dvec()
,
desolve.dvec()
,
format.dvec()
,
implicit_guide.dvec()
,
length.dvec()
,
print.dvec()
,
resolve.classified()
,
resolve.dvec()
,
unclassified.dvec()
library(magrittr)
x <- data.frame(
ID = 1,
CONC = 1,
RACE = 1,
SEX = 1,
DATE = 1
)
x %<>% modify(ID, label = 'subject identifier')
x %<>% modify(CONC, label = 'concentration', guide = 'ng/mL')
x %<>% modify(RACE, label = 'race', guide = list(white = 0, black = 1, asian = 2))
x %<>% modify(SEX, label = 'sex', guide = list(female = 0, male = 1))
x %<>% modify(DATE, label = 'date', guide = '%Y-%m-%d')
x %>% decorations
x %>% explicit_guide %>% decorations
x %>% explicit_guide(DATE) %>% decorations # limit scope
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.