rpivotTable

Enzo Martoglio

2018-01-30

rpivotTable: A pivot table for R

The rpivotTable package is an R htmlwidget built around the pivottable library.

PivotTable.js is a Javascript Pivot Table visualization library with drag’n’drop functionality built on top of jQuery / jQueryUI and written in CoffeeScript (then compiled to JavaScript) by Nicolas Kruchten at Datacratic. It is available under a MIT license

Many thanks to everyone that contributes bugs and prs, and of course thanks to Nicolas Kruchten for PivotTable.js.

Installation

The rpivotTable package depends on htmlwidgets package, so you need to install both packages. You can do this using the devtools package as follows:

Or directly from CRAN:

Usage

Call the package with

Just plug in your data.frame, table or data.table to rpivotTable().

It is as simple as this:

The pivot table should appear in your RStudio Viewer or your browser of choice.

For additional technical information please refer to the examples and explanations here.

rpivotTable parameters decide how the pivot table will look like the firs time it is opened:

For example, to display a table with frequency of colour combinations of eyes and hair, you can specify:

This will display the resulting table. Switching the aggregatorName to Sum as Fraction of Rows will give the row percentages (and the column totals will give the percentages over the gran total).

To display the Hair values in reverse order:

This function could be useful for example to sort time divisions like months of the year or days of the week in their proper, non alphabetical order (thanks to palatinuse for its implementation).

You can also use the very visual new subtotals:

Or if you want to include it as part of your dplyr / magrittr pipeline, you can do that also.

## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

mirror server hosted at Truenetwork, Russian Federation.