I create a interactive pivot table by using rpivotTable
package. However, I found that some of aggregators and renderName are unnecessary for my users. I would like to remove them. For example, I want to remove "Average" from aggregator dropdown menu.
Here is my example:
library(shiny)
library(rpivotTable)
df <- iris
ui <- fluidPage(
fluidRow(
column(width=10, rpivotTableOutput("pivot"))
)
)
server <- function(input, output, session) {
output$pivot<-renderRpivotTable({
rpivotTable(df,
rendererName="Heatmap",
cols=c("Species"),
rows=c("Petal.Width"),
aggregatorName="Count",
hiddenFromAggregators=["Average"]
)
})
}
shinyApp(ui = ui, server = server)
I noticed that there seems some relevant parameters called "hiddenFromAggregators" but I cannot figure out how to apply it in R/Shiny environment.
Here is where I found "hiddenFromAggregators".
https://github.com/nicolaskruchten/pivottable/wiki/Parameters
You may be looking for something like this :
rpivotTable(iris,
rendererName = "Treemap",
cols = c("Species"),
rows = c("Petal.Width"),
aggregatorName = "Count",
aggregators = list(Sum = htmlwidgets::JS('$.pivotUtilities.aggregators["Sum"]'),
Count = htmlwidgets::JS('$.pivotUtilities.aggregators["Count"]')),
subtotals = TRUE)
There is probably a faster way than adding aggregators one by one (using full pivotUtilities.aggregators)
I couldn't find a full list of the default aggregators but you can get it with web inspector on your app (with Google Chrome: right click > inspect) and typing $.pivotUtilities.aggregators
in the console tab.