Row-wise means

row_means(.data, ...)

# S3 method for matrix
row_means(.data, cumulative = FALSE, output_mode, output_class, ...)

# S3 method for data.frame
row_means(.data, cumulative = FALSE, output_mode, output_class, ...)

Arguments

.data

A two-dimensional data structure.

...

Arguments passed on to op_ctrl

na_action

One of ("exclude", "pass"), possibly abbreviated. See stats::na.pass for semantics.

cols

A vector indicating which columns to consider for the operation. If NULL, all columns are used. If its length is 0, no columns are considered. Negative numbers, logical values, character vectors representing column names, and tidyselect::select_helpers are supported.

rows

Like cols but for row indices, and without tidyselect support.

cumulative

Logical. Whether to return the cumulative operation.

output_mode

Passed to op_ctrl(). If missing, it will be inferred.

output_class

Passed to op_ctrl(). If missing, it will be inferred.

Examples

mat <- matrix(rnorm(10L), nrow = 2L, ncol = 5L) row_means(mat)
#> [1] -0.008452961 -0.679009921
# semantically, this is like looking for row means that are different from zero # (but not missing) mat[1L] <- NA_real_ row_means(mat, output_mode = "logical", na_action = "pass")
#> [1] NA TRUE