box_it | R Documentation |
For instance, you can create a Top Two Box variable from a 7-point agreement scale question. Function returns a labelled double binary variable, which will have value label attributes.
box_it(
x,
which = "top",
number = 2,
replace_na = NULL,
lab_str = c("Selected", "Not selected", "Missing value"),
var_label = paste0(which, number),
na_val = 99
)
x |
Variable to be passed through |
which |
Character string to specify which end of spectrum to take values
|
number |
integer value indicating the n to take values from, e.g. 'top n box' or 'bottom n box' |
replace_na |
numeric vector. These values from the variable are replaced
with |
lab_str |
string vector of length 3 containing the labels for the output binary variable. The first value maps to 1 (box selected), the second value maps to 0 (box not selected), and the third values maps to missing values. |
var_label |
string to be used as the variable label, passed through to
|
na_val |
numeric value or NULL, defaults to 99. When set to a number,
this is the number that is used to represent missing values. When set to
NULL, missing values would be stored as |
a binary variable of labelled double type.
box_it(sample(1:10,100,replace = TRUE)) # Converted to binary variable where 9, 10 are selected
box_it(sample(c(1:10, NA),100,replace = TRUE))
# Example where specified numeric values are replaced with NAs
summary(
box_it(
sample(c(1:10, 99), 100, replace = TRUE),
replace_na = 99)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.