Coerce Factor Guide to Something More Implicit
Source:R/explicit_guide_factor.R
implicit_guide.factor.RdCoerces factor 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 'factor'
implicit_guide(x, ...)See also
Other explicit_guide:
explicit_guide(),
explicit_guide.data.frame(),
explicit_guide.dvec(),
explicit_guide.factor(),
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(),
explicit_guide.data.frame(),
format.dvec(),
implicit_guide.dvec(),
length.dvec(),
print.dvec(),
resolve.classified(),
resolve.dvec(),
resolve.factor(),
unclassified.dvec()
Examples
library(magrittr)
x <- data.frame(RACE = factor(1))
x %<>% modify(RACE, label = 'race', guide = list(white = 0, black = 1, asian = 2))
x %>% decorations
#> - RACE
#> - label: race
#> - guide
#> - white: 0
#> - black: 1
#> - asian: 2
x %>% explicit_guide %>% decorations
#> - RACE
#> - label: race
#> - codelist
#> - white: 0
#> - black: 1
#> - asian: 2
x %>% explicit_guide %>% implicit_guide %>% decorations
#> - RACE
#> - label: race
#> - guide
#> - white: 0
#> - black: 1
#> - asian: 2
x %>% explicit_guide(simplify = FALSE) %>% decorations
#> - RACE
#> - label: race
#> - guide
#> - white: 0
#> - black: 1
#> - asian: 2
#> - codelist
#> - white: 0
#> - black: 1
#> - asian: 2
x %>% explicit_guide(simplify = FALSE) %>% implicit_guide %>% decorations
#> - RACE
#> - label: race
#> - guide
#> - white: 0
#> - black: 1
#> - asian: 2
x %<>% explicit_guide
a <- x$RACE
str(a)
#> Factor w/ 1 level "1": 1
#> - attr(*, "label")= chr "race"
#> - attr(*, "codelist")=List of 3
#> ..$ white: num 0
#> ..$ black: num 1
#> ..$ asian: num 2
str(a %>% implicit_guide)
#> Factor w/ 1 level "1": 1
#> - attr(*, "label")= chr "race"
#> - attr(*, "guide")=List of 3
#> ..$ white: num 0
#> ..$ black: num 1
#> ..$ asian: num 2