average_rows: Average values across multiple columns for each row of a...

Description Usage Arguments Value Details See Also

Description

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

Usage

1
average_rows(data, string, kind = "starts", reverse = NULL)

Arguments

data

a data.frame to use for averaging 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".

reverse

a numeric vector indicating items or variables to reverse code using reverse.code from the psych package.

Value

a vector of the averaged values for each row from the specified columns of the data frame.

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

sum_rows for row summing, 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.