Skip to contents

Coerces dvec 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.dvec. If guide attribute is still present, the explicit attribute is removed. Otherwise the explicit element is renamed.

Usage

# S3 method for class 'dvec'
implicit_guide(x, ...)

Arguments

x

dvec

...

ignored

Value

dvec

Examples

library(magrittr)
x <- data.frame(
 ID = as_dvec(1),
 CONC = as_dvec(1),
 RACE = as_dvec(1),
 SEX = as_dvec(1),
 DATE = as_dvec(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
#> - ID
#>  - label: subject identifier
#> - CONC
#>  - label: concentration
#>  - guide: ng/mL
#> - RACE
#>  - label: race
#>  - guide
#>   - white: 0
#>   - black: 1
#>   - asian: 2
#> - SEX
#>  - label: sex
#>  - guide
#>   - female: 0
#>   - male: 1
#> - DATE
#>  - label: date
#>  - guide: '%Y-%m-%d'
x %>% explicit_guide %>% decorations
#> - ID
#>  - label: subject identifier
#> - CONC
#>  - label: concentration
#>  - units: ng/mL
#> - RACE
#>  - label: race
#>  - codelist
#>   - white: 0
#>   - black: 1
#>   - asian: 2
#> - SEX
#>  - label: sex
#>  - codelist
#>   - female: 0
#>   - male: 1
#> - DATE
#>  - label: date
#>  - format: '%Y-%m-%d'
x %>% explicit_guide %>% implicit_guide %>% decorations
#> - ID
#>  - label: subject identifier
#> - CONC
#>  - label: concentration
#>  - guide: ng/mL
#> - RACE
#>  - label: race
#>  - guide
#>   - white: 0
#>   - black: 1
#>   - asian: 2
#> - SEX
#>  - label: sex
#>  - guide
#>   - female: 0
#>   - male: 1
#> - DATE
#>  - label: date
#>  - guide: '%Y-%m-%d'
x %>% explicit_guide %>% implicit_guide(DATE) %>% decorations # limit scope
#> - ID
#>  - label: subject identifier
#> - CONC
#>  - label: concentration
#>  - units: ng/mL
#> - RACE
#>  - label: race
#>  - codelist
#>   - white: 0
#>   - black: 1
#>   - asian: 2
#> - SEX
#>  - label: sex
#>  - codelist
#>   - female: 0
#>   - male: 1
#> - DATE
#>  - label: date
#>  - guide: '%Y-%m-%d'
x %>% explicit_guide(simplify = FALSE) %>% decorations
#> - ID
#>  - label: subject identifier
#> - CONC
#>  - label: concentration
#>  - guide: ng/mL
#>  - units: ng/mL
#> - RACE
#>  - label: race
#>  - guide
#>   - white: 0
#>   - black: 1
#>   - asian: 2
#>  - codelist
#>   - white: 0
#>   - black: 1
#>   - asian: 2
#> - SEX
#>  - label: sex
#>  - guide
#>   - female: 0
#>   - male: 1
#>  - codelist
#>   - female: 0
#>   - male: 1
#> - DATE
#>  - label: date
#>  - guide: '%Y-%m-%d'
#>  - format: '%Y-%m-%d'
x %>% explicit_guide(simplify = FALSE) %>% implicit_guide %>% decorations
#> - ID
#>  - label: subject identifier
#> - CONC
#>  - label: concentration
#>  - guide: ng/mL
#> - RACE
#>  - label: race
#>  - guide
#>   - white: 0
#>   - black: 1
#>   - asian: 2
#> - SEX
#>  - label: sex
#>  - guide
#>   - female: 0
#>   - male: 1
#> - DATE
#>  - label: date
#>  - guide: '%Y-%m-%d'
x %<>% explicit_guide
a <- x$DATE
str(a)
#>  'dvec' num 1
#>  - attr(*, "label")= chr "date"
#>  - attr(*, "format")= chr "%Y-%m-%d"
str(a %>% implicit_guide)
#>  'dvec' num 1
#>  - attr(*, "label")= chr "date"
#>  - attr(*, "guide")= chr "%Y-%m-%d"