pvt: Pivot table

Description Usage Arguments Value Author(s) Examples

View source: R/pivot_table.R

Description

Calculates aggregates in pivot tables

Usage

1
pvt(df, rows = NULL, cols = NULL, ..., .totals = "Total", .keep_total = "all")

Arguments

df

A dataframe

rows

A vector of variable names that will be on the rows of the pivot table

cols

A vector of variable names that will be on the columns of the pivot table

...

calculations that are passed to 'dplyr::summarise()' via the 'pivotr::cube()' function

.totals

A string of how output totals are labeled in the rows and cols

.keep_total

one of "all", "overall", "none"

Value

a tibble

Author(s)

Ismail Muller

Examples

1
2
3
4
5
pvt(mtcars, N = n())
pvt(mtcars, cyl, am, N = n(), Avg = mean(mpg))
pvt(mtcars, cyl, am, Avg = mean(wt), N = n())
pvt(mtcars, NULL, am, Avg = mean(wt))
pvt(mtcars, c(vs, am), cyl, N = n(), .keep_total = "overall")

ismailmuller/pivotr documentation built on May 4, 2020, 4:28 a.m.