Add a new level to a variables which is the sum of all other levels.
add_total_level_to_var(
df,
variable,
level_name = "Total",
sum_var = "value",
na.rm = TRUE
)
A data frame
Data frame to add total levels to.
Name of variable to add total level to.
Total level name.
String, name of variable to sum over.
Optional. Logical. If TRUE, NAs are removed before summing.