d <- tibble(v1 = c(1, 2, 2, 2, 5, 6), v2 = c(1:3, 1:3))
d <- d %>%
set_value_labels(v1 = c(agree=1, disagree=2, dk=5, refused=6)) %>%
set_na_values(v1 = 5:6)
d$v1
## <labelled_spss<double>[6]>
## [1] 1 2 2 2 5 6
## Missing values: 5, 6
##
## Labels:
## value label
## 1 agree
## 2 disagree
## 5 dk
## 6 refused
https://cran.r-project.org/web/packages/labelled/vignettes/intro_labelled.html
https://stackoverflow.com/questions/43529972/set-missing-values-for-multiple-labelled-variables
Reproducibility receipt
## datetime
Sys.time ()
## [1] "2020-06-04 14:51:53 BST"
sessionInfo()
## R version 4.0.0 (2020-04-24)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19041)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=English_United States.1252
## [2] LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] labelled_2.4.0 dplyr_1.0.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.4.6 knitr_1.28 magrittr_1.5 hms_0.5.3
## [5] tidyselect_1.1.0 R6_2.4.1 rlang_0.4.6 stringr_1.4.0
## [9] tools_4.0.0 xfun_0.14 htmltools_0.4.0 ellipsis_0.3.1
## [13] yaml_2.2.1 digest_0.6.25 tibble_3.0.1 lifecycle_0.2.0
## [17] crayon_1.3.4 purrr_0.3.4 vctrs_0.3.0 glue_1.4.1
## [21] evaluate_0.14 haven_2.3.0 rmarkdown_2.2 stringi_1.4.6
## [25] compiler_4.0.0 pillar_1.4.4 forcats_0.5.0 generics_0.0.2
## [29] pkgconfig_2.0.3