sum_rows: Sum values across multiple columns for each row of a...

Description Usage Arguments Value Details See Also

Description

Sum values across multiple columns for each row of a data.frame

Usage

1
sum_rows(data, string, kind = "starts")

Arguments

data

a data.frame to use for summing across rows

string

a string that can be used in dplyr's select function.

kind

a string indicating which type of dplyr select helper functions. Appropriate values are "starts", "ends", or "matches".

Value

a data.frame with the newly created variable

Details

This function, and those specified below in 'See Also', work best when used inside a call to dplyr's mutate() for creating new variables. The point of the function is to make it easy to use regular expressions to select variables for aggregation, such as an average score for a number of questionnaire items or the sum of correct responses.

See Also

average_rows for row averaging across rows, sum_missings for summing missing values, and sd_rows for calculating standard deviations across rows.


ethan-young/esyr documentation built on May 15, 2019, 12:45 p.m.