implicit_guide.data.frame: Coerce Data Frame Guide to Something More Implicit

View source: R/explicit_guide.R

implicit_guide.data.frameR Documentation

Coerce Data Frame Guide to Something More Implicit

Description

Coerces data.frame guide-like attributes to 'guide'. 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 these with 'guide': i.e., to undo the effects of explicit_guide.data.frame. If guide attribute is still present, the explicit attribute is removed. Otherwise the explicit element is renamed.

Usage

## S3 method for class 'data.frame'
implicit_guide(x, ..., collapse = getOption("yamlet_collapse_codelist", 10))

Arguments

x

data.frame

...

named arguments ignored; un-named arguments limit scope

collapse

numeric: substitute empty codelist if number of levels exceeds this. Set to Inf to ensure levels are always stored explicitly; if zero, empty codelist will always be substituted if codelist elements are un-named and exactly match sort(unique(x)).

Value

data.frame

See Also

Other explicit_guide: explicit_guide(), explicit_guide.data.frame(), explicit_guide.dvec(), explicit_guide.yamlet(), implicit_guide(), implicit_guide.dvec(), infer_guide()

Examples

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 %>% implicit_guide %>% decorations
x %>% explicit_guide %>% implicit_guide(DATE) %>% decorations # limit scope
x %>% explicit_guide(simplify = FALSE) %>% decorations
x %>% explicit_guide(simplify = FALSE) %>% implicit_guide %>% decorations

yamlet documentation built on Oct. 11, 2024, 9:06 a.m.