View source: R/sub_nonanswers.R
sub_nonanswers | R Documentation |
This is a convenience function for removing what might be considered non-answers ("don't know", "refused", etc.) and rescaling the remaining values to add to 1.0.
sub_nonanswers(
data,
response = response,
value = value,
nons = c("Don't know", "Refused"),
factor_response = TRUE,
rescale = FALSE
)
data |
A data frame |
response |
Bare column name of where responses are found, including those considered to be non-answers. Default: response |
value |
Bare column name of values, Default: value |
nons |
Character vector of responses to be removed. Default: c("Don't know", "Refused") |
factor_response |
Logical: if |
rescale |
Logical: if |
A data frame with the same number of columns as the original, but fewer rows
if (interactive()) {
xt <- system.file("extdata/test_xtab2018.xlsx", package = "cwi")
df <- read_xtabs(xt, process = TRUE) |>
dplyr::filter(code == "Q1") |>
sub_nonanswers()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.