aggregate_and_document_scale | R Documentation |
The resulting variables will have the attribute scale_item_names
containing
the basis for aggregation. Its label
attribute will refer to the common stem of the
aggregated variable names (if any), the number of variables, and the
aggregation function.
aggregate_and_document_scale(items, fun = rowMeans, stem = NULL)
items |
data.frame of the items that should be aggregated |
fun |
aggregation function, defaults to rowMeans with na.rm = FALSE |
stem |
common stem for the variables, specify if it should not be auto-detected as the longest common stem of the variable names |
testdf <- data.frame(bfi_neuro_1 = rnorm(20), bfi_neuro_2 = rnorm(20),
bfi_neuro_3R = rnorm(20), age = rpois(20, 30))
item_names <- c('bfi_neuro_1', 'bfi_neuro_2', 'bfi_neuro_3R')
testdf$bfi_neuro <- aggregate_and_document_scale(testdf[, item_names])
testdf$bfi_neuro
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.