| row_calculation | R Documentation |
Perform row wise calculations on numeric variables.
row_calculation(data_frame, statistics, ..., round_digits = NULL)
data_frame |
A data frame in which are the values to be calculated. |
statistics |
Available functions: "sum", "freq", "mean", "median", "mode", "min", "max". |
... |
Variable names of the value variables. |
round_digits |
The number of decimal places the values should be rounded to. |
Returns a numeric vector.
# Example data frame
my_data <- data.frame(var1 = 1:5,
var2 = c(6, 7, 8, NA, 10),
var3 = 11:15)
# Calculate new variables
my_data[["sum"]] <- my_data |> row_calculation("sum", var1, var2, var3)
my_data[["mean"]] <- my_data |> row_calculation("mean", var1:var3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.