tidyselect_row_sums: Calculate row sums & means tidyselect-safely.

Description Usage Arguments Value Examples

Description

Wrapper around rowSums etc. to allow calculating row sums and means of flexibly supplied column names from a df. Accepts select_helpers. Designed for external use in pipe-chains, outside of mutate.

Usage

1
2
3
tidyselect_row_sums(.data, ..., .value = "row_sum", na.rm = FALSE)

tidyselect_row_means(.data, ..., .value = "row_mean", na.rm = FALSE)

Arguments

.data

A tbl: a data.frame or tibble.

...

One or more unquoted variable names. Accepts select_helpers.

.value

The name of the new column, as a string.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

Value

An object of the same class as .data, with the computed column added.

Examples

1
2
3
4
data <- tibble::tibble(x1 = 1:5, x2 = 1:5, x3 = 1:5)

tidyselect_row_sums(data, dplyr::starts_with("x"))
tidyselect_row_means(data, dplyr::starts_with("x"))

cu-psych-r-users/cuPsychRTools documentation built on July 25, 2019, 5:39 p.m.