calc_factor_sum | R Documentation |
This function takes a dataframe, and a series of variables and calculates the rowwise sum. It should be usefull to calculate factor scores out of several variables
calc_factor_sum(.data, ...)
.data |
A dataframe |
... |
Variables to sum. Select variables DPLYR style. One or more unquoted expressions separated by commas. You can treat variable names like they are positions, so you can use expressions like x:y to select ranges of variables You can also pass variables as vector of strings |
Beware that * The output is a vector of numeric values. To use this in a piping syntax see the example below - note the use of '.' in the pipe worlflow * The sum throws out the missing values (na.rm = TRUE) so you will always get a sum despite the missing values in you variables
A vector of numeric values representing the factor scores per subject
mtcars %>% dplyr::mutate(score = calc_factor_sum(., mpg, cyl)) %>% head()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.