rpivotTable: pivottable for R

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

PivotTable.js is a Javascript Pivot Table library with drag'n'drop functionality built on top of jQuery/jQueryUI and written in CoffeeScript by Nicolas Kruchten at Datacratic. It is available under an MIT license


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

devtools::install_github(c("ramnathv/htmlwidgets", "smartinsightsfromdata/rpivotTable"))


Just plug in your data.frame or data.table (e.g. dt) to rpivotTable().

It is as simple as this:


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

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 pivot table with frequency of colour combinations of eyes and hair, you can specify:

rpivotTable(data = HairEyeColor, rows = "Hair",cols="Eye", vals = "Freq", aggregatorName = "Sum", rendererName = "Table", width="100%", height="400px")

This will display a cross tab with the frequency of eyes by hair colour. Dragging & dropping (slicing & dicing) categorical variables in rows and columns changes the shape of the table.

If you want to include it as part of your dplyr / magrittr pipeline, you can do that also:

iris %>%
tbl_df %>%
filter( Sepal.Width > 3 ) %>%