View source: R/generate_modifiers.R
| add_row_total | R Documentation |
Add a row total
add_row_total(
data,
position = c("bottom", "top"),
label_total = "Total",
fill = "-"
)
data |
A data frame, tibble, or |
position |
Position to add the total row. Either "bottom" (default) or "top". |
label_total |
Label for the total row in the category column. Default is "Total". |
fill |
Character. Value to fill in for missing numeric columns in the total row. Default is "-". |
The input data frame with an additional row representing the total of numeric columns.
# Example data frame
df <- data.frame(
category = c("A", "B", "C"),
value1 = c(10, 20, 30),
value2 = c(5, 15, 25)
)
df_with_total <- add_row_total(df)
df_with_total_top <- add_row_total(df, position = "top")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.