#' Rescale level of being acceptable
#'
#' Rescale 3-level categorical variables
#' \code{"Always acceptable"}, \code{"Sometimes acceptable"} and \code{"Never acceptable"}.
#' This is a wrapper function around the the \code{\link{rescale_categories}} function.
#' @param column A column from a survey data frame where
#' level of being acceptable is recorded with only three levels.
#' @param from Defaults to \code{c("always", "sometimes", "never")}.
#' @param to Defaults to \code{c(1,0.5,0)} )
#' @param na_labels Defaults to \code{c("NA","DK")}
#' @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 underscore Defaults to \code{TRUE} in which case factor names or character strings
#' contain underscore_between_words. This is a better approach for further programming,
#' but you can choose \code{FALSE} for nicer printing results. See examples.
#' @param return_class Default is \code{"numeric"}, alternatives \code{"character"} or
#' \code{"factor"}.
#' @examples
#' rescale_acceptable_3 (column = c("Always acceptable",
#' "Sometimes acceptable",
#' "Never acceptable",
#' "NA", "DK"))
#'
#'
#' rescale_acceptable_3(column =
#' c("Always acceptable",
#' "Sometimes acceptable",
#' "Never acceptable",
#' "NA", "DK"),
#' na_labels = "default",
#' return_class = "character")
#' @export
rescale_acceptable_3 <- function ( column,
from = c("Always acceptable",
"Sometimes acceptable",
"Never acceptable"),
to = c(1,0.5,0),
na_labels = c("NA","DK"),
underscore = TRUE,
exact_from = TRUE,
return_class = "numeric" ) {
if ( return_class %in% c("character", "factor")) {
to <- c("always", "sometimes", "never")
if (underscore == FALSE) {
to <- gsub("_", " ", to)
}
}
return(rescale_categories(column = column,
from = from, to = to,
na_labels = na_labels,
exact_from = exact_from,
return_class = return_class))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.