Compute statistics for the active dimension and add them as columns to the corresponding metadata. Requires rows or columns to be active.
Examples
mat <- matrix(rnorm(20), nrow = 4, ncol = 5)
tm <- tidymatrix(mat)
# Add row statistics
tm <- tm |>
activate(rows) |>
add_stats(mean, var, sd)
# Now row_data has columns: mean, var, sd
# Add column statistics
tm <- tm |>
activate(columns) |>
add_stats(median, min, max)
# Custom names
tm <- tm |>
activate(rows) |>
add_stats(mean, var, .names = c("row_mean", "row_var"))