rescale_categories: Rescale categories

Description Usage Arguments Examples

Description

A generic function to rescale categorical variables.
There are wrapper functions available for the Eurobarometer trend and demography questions with the default GESIS codes:
For example:
rescale_marital_status for marital status.
rescale_occupation for occupation and last job.
rescale_social_class_en for class self-placement.
The get_answer_options functions lists all the currently recognized standard values.

Usage

1
2
rescale_categories(column, from = c("Agree", "Disagree"), to = c(1, 0),
  na_labels = NULL, exact_from = TRUE, return_class = "numeric")

Arguments

column

A column from a survey data frame with categorical variables.

from

Defaults to c("Agree", "Disagree"). Shorthened categories can be used, to, in this case the first part of the character string is matched, for example, "Totally agree" in case of from = "totally" is matched for the first six characters, "not agree" in case of from = "not" is matched against the first three characters.

to

Defaults to c(1,0).

na_labels

Defaults to NULL. The pre-coded profiles can be accessed via get_na_labels.

exact_from

Deafults to TRUE. If FALSE you can use the partial matching, but beware that in this case, "twenty" will be replaced by 20, and "twenty-one" will be already matched with "twenty".

return_class

Default is "numeric", alternatives "character" or "factor".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
rescale_categories (column =
        c("Agree", "AGREE", "disagree",
          "DK", "Refusal (SPONT.)", "Disagree"),
        na_labels = c("DK", "Refusal (SPONT.)")
        )

rescale_categories (column =
        c("Agree", "AGREE", "disagree",
          "DK", "Refusal (SPONT.)", "Disagree"),
        na_labels = "default")

rescale_categories (column = c("Agree", "AGREE", "disagree"))

antaldaniel/surveyreader documentation built on May 16, 2019, 2:29 a.m.