R/rescale_social_class_en.R

#' Rescale social class self-assessment in English
#'
#' Rescaling the Eurobarometer social class self-assessment variables.
#' This is a wrapper function around the the \code{\link{rescale_categories}} function.
#' @param column A column from a survey data with a four-level agreement scale.
#' @param from Defaults to \code{c("NULL")} in which case the GESIS coding in English
#' will be used.
#' @param to Defaults to \code{NULL} in which case the GESIS coding will be
#' shortened to \code{c("working", "middle", "upper", "other", "none", "refusal", NA)}
#' @param na_labels  Defaults to \code{c("default")}.
#' @param exact_from Deafults to \code{TRUE}. If \code{FALSE} you can use the
#' partial matching, but beware that in this case, \code{"twenty"} will be replaced by
#' @param return_class Default is \code{"factor"}, alternatives \code{"character"} or
#' \code{"numeric"}.
#' @examples
#' rescale_social_class_en (c("The working class of society",
#'                    "None (SPONTANEOUS)",
#'                    "The middle class of society",
#'                    "DK"),
#'                   return_class = "character")
#'
#' @export

rescale_social_class_en <- function ( column,
                          from = NULL,
                          to = NULL,
                          exact_from = TRUE,
                          na_labels = c("default"),
                          return_class = "factor") {

  if (is.null(from)) {
         from = c("The working class of society",
                  "The middle class of society",
                  "The upper class of society",
                  "Other (SPONTANEOUS)",
                  "None (SPONTANEOUS)",
                  "Refusal (SPONTANEOUS)",
                  "DK")
  }

  if(is.null(to)) {
        to = c("working", "middle", "upper",
               "other", "none", "refusal", NA)
  }

  return(rescale_categories(column = column,
                            from = from, to = to,
                            na_labels = na_labels,
                            exact_from = exact_from,
                            return_class = return_class))

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