View source: R/harmonize_values.R
harmonize_values | R Documentation |
Create a labelled vector with harmonized numeric coding and value labels.
harmonize_values(
x,
harmonize_label = NULL,
harmonize_labels = NULL,
na_values = c(do_not_know = 99997, declined = 99998, inap = 99999),
na_range = NULL,
id = "survey_id",
name_orig = NULL,
remove = NULL,
perl = FALSE
)
x |
A labelled vector |
harmonize_label |
A character vector of 1L containing the new,
harmonize variable label. Defaults to |
harmonize_labels |
A list of harmonization values |
na_values |
A named vector of |
na_range |
A min, max range of |
id |
A survey ID, defaults to |
name_orig |
The original name of the variable. If left |
remove |
Defaults to |
perl |
Use perl-like regex? Defaults to |
Create a labelled vector that contains in its metadata attributes the original labelling, the original numeric coding and the current labelling, with the numerical values representing the harmonized coding.
A labelled vector that contains in its metadata attributes the original labelling, the original numeric coding and the current labelling, with the numerical values representing the harmonized coding.
Other harmonization functions:
collect_val_labels()
,
crosswalk_surveys()
,
crosswalk_table_create()
,
harmonize_na_values()
,
harmonize_survey_values()
,
harmonize_var_names()
,
label_normalize()
Other harmonization functions:
collect_val_labels()
,
crosswalk_surveys()
,
crosswalk_table_create()
,
harmonize_na_values()
,
harmonize_survey_values()
,
harmonize_var_names()
,
label_normalize()
var1 <- labelled::labelled_spss(
x = c(1,0,1,1,0,8,9),
labels = c("TRUST" = 1,
"NOT TRUST" = 0,
"DON'T KNOW" = 8,
"INAP. HERE" = 9),
na_values = c(8,9))
harmonize_values (
var1,
harmonize_labels = list (
from = c("^tend\\sto|^trust", "^tend\\snot|not\\strust", "^dk|^don", "^inap"),
to = c("trust", "not_trust", "do_not_know", "inap"),
numeric_values = c(1,0,99997, 99999)),
na_values = c("do_not_know" = 99997,
"inap" = 99999),
id = "survey_id"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.