Skip to contents

Finish incomplete haven attributes substituting missings with values

Usage

haven_all_levels(data)

Arguments

data

haven labelled variable

Value

named vector

Examples

ds <- structure(c(1, 2, 3, 2, 10, 9),
  labels = c(Unknown = 9, Refused = 10),
  class = "haven_labelled"
)
labelled::is.labelled(ds)
#> Error in loadNamespace(x): there is no package called ‘labelled’
attributes(ds)
#> $labels
#> Unknown Refused 
#>       9      10 
#> 
#> $class
#> [1] "haven_labelled"
#> 
ds |> haven_all_levels()
#>       1       2       3 Unknown Refused 
#>       1       2       3       9      10