Compute sum/mean/sd/median/max/min/custom function on rows/columns
sum_row(..., na.rm = TRUE) sum_col(..., na.rm = TRUE) mean_row(..., na.rm = TRUE) mean_col(..., na.rm = TRUE) sd_row(..., na.rm = TRUE) sd_col(..., na.rm = TRUE) median_row(..., na.rm = TRUE) median_col(..., na.rm = TRUE) max_row(..., na.rm = TRUE) max_col(..., na.rm = TRUE) min_row(..., na.rm = TRUE) min_col(..., na.rm = TRUE) apply_row(fun, ...) apply_col(fun, ...) any_in_row(..., na.rm = TRUE) any_in_col(..., na.rm = TRUE) all_in_row(..., na.rm = TRUE) all_in_col(..., na.rm = TRUE)
... |
data. Vectors, matrixes, data.frames, list. Shorter arguments will be recycled. |
na.rm |
logical. Contrary to the base 'sum' it is TRUE by default. Should missing values (including NaN) be removed? |
fun |
custom function that will be applied to ... |
All functions except apply_*
return numeric vector of length
equals the number of argument columns/rows. Value of apply_*
depends
on supplied fun
function.
iris = compute(iris, { new_median = median_row(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width) new_mean = mean_row(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width) }) dfs = data.frame( test = 1:5, aa = rep(10, 5), b_ = rep(20, 5), b_1 = rep(11, 5), b_2 = rep(12, 5), b_4 = rep(14, 5), b_5 = rep(15, 5) ) # calculate sum of b* variables compute(dfs, { b_total = sum_row(b_, b_1 %to% b_5) }) # conditional modification do_if(dfs, test %in% 2:4, { b_total = sum_row(b_, b_1 %to% b_5) })
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.