Skip to contents

Coerces dvec to 'classified': a factor with a codelist attribute. Results may differ if explicit_guide() is called first.

Usage

# S3 method for class 'dvec'
classified(
  x,
  ...,
  exclude = NA,
  ordered = is.ordered(x),
  nmax = NA,
  token = character(0)
)

Arguments

x

dvec

...

un-named arguments ignored. Named arguments passed to classified.default to modify behavior

exclude

see factor

ordered

see factor

nmax

see factor

token

informative label for messages

Value

classified

Examples

library(magrittr)
x <- as_dvec(1:3)
attr(x, 'guide') <- list(a = 1, b = 2, c = 3)
x %>% str
#>  'dvec' int [1:3] 1 2 3
#>  - attr(*, "guide")=List of 3
#>   ..$ a: num 1
#>   ..$ b: num 2
#>   ..$ c: num 3
x %>% classified %>% str
#>  Factor w/ 3 levels "1","2","3": 1 2 3
#>  - attr(*, "guide")=List of 3
#>   ..$ a: num 1
#>   ..$ b: num 2
#>   ..$ c: num 3
#>  - attr(*, "codelist")=List of 3
#>   ..$ : chr "1"
#>   ..$ : chr "2"
#>   ..$ : chr "3"
x %>% explicit_guide %>% classified %>% str
#>  Factor w/ 3 levels "a","b","c": 1 2 3
#>  - attr(*, "codelist")=List of 3
#>   ..$ 1: chr "a"
#>   ..$ 2: chr "b"
#>   ..$ 3: chr "c"