score_scale | R Documentation |
Score scale calculates scale scores.
score_scale(
data,
filter,
sum = FALSE,
min_valid = 1,
max_na = NA,
label = NULL,
fun = NULL,
var_weight = NULL,
var_recoding = NULL
)
data |
A data frame |
filter |
A logical expression for any dic attribute (e.g. |
sum |
If |
min_valid |
Minimal number of valid values that is required for calculating the mean. A value between 0 and 1 indicates a proportion of values (e.g., 0.5 = 50 percent of values have to be valid). |
max_na |
Maximum number of NAs that are allowed before returning NA. A value between 0 and 1 indicates a proportion of values (e.g., 0.5 = 50 percent NAs are allowed). |
label |
A character string with a label for the resulting score variable. Automatically generated if label is not set. |
fun |
A function for calculating the score (e.g., |
var_weight |
Name of the dic attribute that is applied to derive
weights. Defaults to |
If you provide your own function, the first argument of that function must take the vector of values and the second argument the weights.
A data frame
dat <- apply_dic(ex_scaledic_data, ex_scaledic_dic)
# apply the default weighted mean function
score_scale(dat, scale == "rel", label = "Religious beliefs")
# apply the weighted sum function
score_scale(dat, scale == "rel", label = "Religious beliefs", sum = TRUE)
# provide an external function (here the weighted median function from the spatstat package)
score_scale(dat, scale == "rel", label = "Religious beliefs", fun = spatstat.geom::weighted.median)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.