add_row_totals: Add row totals for a set of columns in a dataframe

Description Usage Arguments Value

View source: R/totals.R

Description

Calculates row totals for a set of columns in a dataframe and add them as a new column at the end of the dataframe.

Usage

1
add_row_totals(data, from = 2, to = ncol(data), na.rm = FALSE, label = "total")

Arguments

data

A dataframe containing columns of numerical data to be summed by row.

from

The number or name of the column from which row 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 row totals are calculated. The default is ncol(data), which means row totals are calculated across all remaining columms 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 column. The default is "total".

Value

A tibble containing row totals and any preceding columns.


olihawkins/cltools documentation built on Sept. 14, 2020, 7:25 a.m.