Description Usage Arguments Examples
Use pivottable.js in R with the power and convenience of a htmlwidget.
1 2 3 4 |
data |
data.frame or data.table (R>=1.9.6 for safety) with data to use in the pivot table |
rows |
String name of the column in the data.frame to prepopulate the rows of the pivot table. |
cols |
String name of the column in the data.frame to prepopulate the columns of the pivot table. |
aggregatorName |
String name of the pivottable.js aggregator to prepopulate the pivot table. |
vals |
String name of the column in the data.frame to use with |
rendererName |
List name of the renderer selected, e.g. Table, Heatmap, Treemap etc. |
sorter |
String name this allows to implement a javascript function to specify the ad hoc sorting of certain values. See vignette for an example. It is especially useful with time divisions like days of the week or months of the year (where the alphabetical order does not work). |
exclusions |
String this optional parameter allows to filter the members of a particular dimension "by exclusion". Using the 'Titanic' example, to display only the "1st", "2nd" and "3rd" members in the "Class" dimension, it is convenient to filter by exclusion using 'exclusions=list(Class="Crew")'. Please note that this only pre-selects the visible filter(s) on the pivot table: the other dimension members are still availabe for selection if needed. |
inclusions |
List this optional parameter allows to filter the members of a particular dimension "by inclusion". Using the 'Titanic' example, to display only the "Crew" member in the "Class" dimension, it is convenient to filter by inclusion using 'inclusions=list(Class="Crew")'. Please note that this only pre-selects the visible filter(s) on the pivot table: the other dimension members are still availabe for selection if needed. |
locale |
|
subtotals |
Logical this optional parameter allows use of the pivottable subtotal plugin. Using this parameter will set all renderer names to the english locale. |
... |
list other parameters that
can be passed to |
width |
width parameter |
height |
height parameter |
elementId |
String valid CSS selector id for the rpivotTable container. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # use Titanic dataset provided in base R - simple creation with just data
rpivotTable( Titanic )
# prepopulate multiple columns and multiple rows
rpivotTable( Titanic, rows = c("Class","Sex"), cols = c("Age","Survived" ) )
# A more complete example:
rpivotTable(
Titanic,
rows = "Survived",
cols = c("Class","Sex"),
aggregatorName = "Sum as Fraction of Columns",
vals = "Freq",
rendererName = "Table Barchart"
)
# An example with inclusions and exclusions filters:
rpivotTable(
Titanic,
rows = "Survived",
cols = c("Class","Sex"),
aggregatorName = "Sum as Fraction of Columns",
inclusions = list( Survived = list("Yes")),
exclusions= list( Class = list( "Crew")),
vals = "Freq",
rendererName = "Table Barchart"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.