Get means, sums and possibly other functions for a select number
of columns using dplyr::select
-style column selection.
row_sums(data, ..., na_rm = FALSE, varname = "sum") row_means(data, ..., na_rm = FALSE, varname = "mean") row_min(data, ..., na_rm = FALSE, varname = "min") row_max(data, ..., na_rm = FALSE, varname = "max") row_apply(data, ..., .fun, varname = "var")
data | A data frame. |
---|---|
... | The columns to sum, take the mean of, etc. Required. |
na_rm | Whether to remove |
varname | The column name of the sums means etc. as a character string. |
.fun | The function to apply. |
A data frame with a new column representing the sums, means or whatever.
Simple wrappers for applying rowwise operations only for selected
columns within the tidyverse approach to data processing. The
row_apply
function requires a function that already works on rows.
#> x y z sum #> 1 1 4 7 5 #> 2 2 5 8 7 #> 3 3 6 9 9#> x y z mean #> 1 1 4 7 4 #> 2 2 5 8 5 #> 3 3 6 9 6#> # A tibble: 3 x 3 #> x y max #> <int> <int> <int> #> 1 1 4 4 #> 2 2 5 5 #> 3 3 6 6#> x y z var #> 1 1 4 7 147 #> 2 2 5 8 258 #> 3 3 6 9 369