Learn R Programming

yamlet (version 0.4.8)

explicit_guide.data.frame: Coerce Data Frame Guide to Something More Explicit

Description

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.

Usage

# S3 method for data.frame
explicit_guide(x, overwrite = TRUE, ...)

Arguments

x

yamlet

overwrite

passed as TRUE

...

Value

yamlet

Details

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.

See Also

Other explicit_guide: explicit_guide.yamlet(), explicit_guide()

Examples

Run this code
# NOT RUN {
library(magrittr)
x <- data.frame(
 ID = 1,
 CONC = 1,
 RACE = 1,
 SEX = 1,
 DATE = 1
)
x$ID   %<>% structure(label = 'subject identifier')
x$CONC %<>% structure(label = 'concentration', guide = 'ng/mL')
x$RACE %<>% structure(label = 'race', guide = list(white = 0, black = 1, asian = 2))
x$SEX  %<>% structure(label = 'sex', guide = list(female = 0, male = 1))
x$DATE %<>% structure(label = 'date', guide = '%Y-%m-%d')
x %>% as_yamlet
x %>% explicit_guide %>% as_yamlet
# }

Run the code above in your browser using DataLab