averages_row: averages_row

Description Usage Arguments Examples

View source: R/summary-row.R

Description

add a averages summary row to a data frame. This is a wrapper around the summary_row function.

Usage

1
2
averages_row(df, cols, rows = NA, label_col = NA, label = "Averages",
  new_row = TRUE, fill = NA)

Arguments

df

the data frame

cols

numeric vector of columns to include in the summary row

rows

numeric vector of rows to include in summary calculation. By default rows is set to all rows that were not created by the a summary_row function.

label_col

column number to hold the summary row label specified by the label argument

label

summary row label. defaults to "Averages"

new_row

boolean value indicating whether the summary row should be a new row attached to the bottom of the data frame or if it should be combined with an already existing summary row.

fill

value to insert in columns not specified in the cols argument. Default is NA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
df <- data.frame("year" = 2014:2016,
                 "a" = c(NA, 1, 3),
                 "b" = c("g", "e", "f")
      )

averages_row(df = df, cols = 2)
averages_row(df = df, cols = 2, label_col = 1, label = "Totals")

df$d <- 5:7

# add new row
averages_row(df = df, cols = c(2, 4), label_col = 1, label = "Totals")

merlinoa/summaryrow documentation built on May 22, 2019, 6:53 p.m.