calc_factor_sum: Calculates factor scores by summing the variables

calc_factor_sumR Documentation

Calculates factor scores by summing the variables

Description

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

Usage

calc_factor_sum(.data, ...)

Arguments

.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

Details

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

Value

A vector of numeric values representing the factor scores per subject

Examples

mtcars %>% dplyr::mutate(score = calc_factor_sum(., mpg, cyl)) %>% head()

lefkiospaikousis/lpmisc documentation built on July 19, 2022, 3:16 a.m.