Skip to contents

Resolves implicit usage of default key 'guide' to explicit usage for factor. Calls explicit_guide followed by classified. If option yamlet_with_title is not NULL, and if 'units' present, label and units will be concatenated by default to create a title attribute (but this is generally unexpected).

Usage

# S3 method for class 'factor'
resolve(x, ...)

Arguments

x

factor

...

passed to explicit_guide, classified, and make_title

Value

classified

Details

If decorating a factor with a guide, it is recommended to supply one that resolves to a codelist. An even safer practice is to convert the factor first to character, so that there are no factor levels to disagree with the (somewhat equivalent) codelist.

Examples

library(magrittr)
x <- factor(1:3)
attr(x, 'guide') <- list(a = 1, b = 2, c = 3)
x
#> [1] 1 2 3
#> attr(,"guide")
#> attr(,"guide")$a
#> [1] 1
#> 
#> attr(,"guide")$b
#> [1] 2
#> 
#> attr(,"guide")$c
#> [1] 3
#> 
#> Levels: 1 2 3
resolve(x)
#> [1] a b c
#> attr(,"codelist")
#> attr(,"codelist")$`1`
#> [1] a
#> 
#> attr(,"codelist")$`2`
#> [1] b
#> 
#> attr(,"codelist")$`3`
#> [1] c
#> 
#> Levels: a b c
x <- data.frame(bar = x)
x
#>   bar
#> 1   1
#> 2   2
#> 3   3
resolve(x)
#>   bar
#> 1   a
#> 2   b
#> 3   c