Description Usage Arguments Value Examples
View source: R/psychometrics.R
Calculate the total scores from sets of scores
1 | total_scores(.data, ..., .method = "mean", .append = FALSE)
|
.data |
A data frame with columns to summed or averaged over. |
... |
A comma separated set of named tidy selectors, each of which selects a set of columns to which to apply the totalling function. |
.method |
The method used to calculate the total. Must be one of "mean", "sum", or "sum_like". The "mean" is the arithmetic mean, skipping missing values. The "sum" is the sum, skipping missing values. The "sum_like" is the arithmetic mean, again skipping missing values, multiplied by the number of elements, including missing values. |
.append |
logical If FALSE, just the totals be returned. If TRUE, the totals are appended as new columns to original data frame. |
A new data frame with columns representing the total scores.
1 2 3 4 5 6 | # Calculate the mean of all items beginning with `x_` and separately all items beginning with `y_`
total_scores(test_psychometrics, x = starts_with('x'), y = starts_with('y'))
# Calculate the sum of all items beginning with `z_` and separately all items beginning with `x_`
total_scores(test_psychometrics, .method = 'sum', z = starts_with('z'), x = starts_with('x_'))
# Calculate the mean of all items from `x_1` to `y_10`
total_scores(test_psychometrics, xy = x_1:y_10)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.