Learn R Programming

janitor (version 0.3.0)

adorn_totals: Append a totals row and/or column to a data.frame.

Description

This function excludes the first column of the input data.frame, assuming it's a descriptive variable not to be summed. It also excludes other non-numeric columns.

Usage

adorn_totals(dat, which = c("row", "col"), fill = "-", na.rm = TRUE)

Arguments

dat

an input data.frame with at least one numeric column.

which

one of "row", "col", or c("row", "col")

fill

if there are multiple non-numeric columns, what string should fill the bottom row of those columns?

na.rm

should missing values (including NaN) be omitted from the calculations?

Value

Returns a data.frame augmented with a totals row, column, or both.

Examples

Run this code
# NOT RUN {
mtcars %>%
  crosstab(am, cyl) %>%
  adorn_totals()
# }

Run the code above in your browser using DataLab