Learn R Programming

pivottabler (version 0.4.0)

qpvt: Quickly build a basic pivot table.

Description

The qpvt function builds a basic pivot table with one line of R.

Usage

qpvt(dataFrame, rows = NULL, columns = NULL, calculations = NULL, ...)

Arguments

dataFrame

The data frame containing the data to be summarised in the pivot table.

rows

A character vector of variable names to be plotted on the rows of the pivot table, or "=" to specify the position of the calculations.

columns

A character vector of variable names to be plotted on the columns of the pivot table, or "=" to specify the position of the calculations.

calculations

One or more summary calculations to use to calculate the values of the cells in the pivot table.

...

Additional arguments, currently format, formats, totals and/or argumentCheckMode.

Value

A pivot table.

Examples

Run this code
# NOT RUN {
qpvt(bhmtrains, "TOC", "TrainCategory", "n()")
qpvt(bhmtrains, c("=", "TOC"), c("TrainCategory", "PowerType"),
     c("Number of Trains"="n()",
       "Maximum Speed"="max(SchedSpeedMPH, na.rm=TRUE)"))
# }

Run the code above in your browser using DataLab