Description Usage Arguments Value
Calculates column totals for a set of columns in a dataframe and add them
as a new row at the end of the dataframe. A label for the total row is
added to each of the columns indicated by the label_col
argument.
Label columns must be character vectors. NAs are added to any columns
not summed or specified as label columns.
1 2 3 4 5 6 7 8 9 |
data |
A dataframe containing columns of numerical data to be summed by column. |
from |
The number or name of the column from which column totals are calculated. The default is 2, assuming one column for row labels. Use 1 if there are no preceding data columns. |
to |
The number or name of the column to which column totals are calculated. The default is ncol(data), which means column totals are calculated for all remaining columms in the dataframe. |
rows |
A numeric vector of the rows to be summed. The default is all rows in the dataframe. |
na.rm |
A boolean which if TRUE ignores NAs in calculating totals. The default value is FALSE. |
label |
The label for the totals row. The default is "total". |
lcols |
A vector or scalar containing the indices of the columns to to which to add the total label. These columns must be character vectors. The default is 1, assuming one column for row labels. Invalid label columns are silently ignored. |
A tibble containing the input dataframe with an additional row for column totals.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.