我使用rpivotTable包创建了一个交互式的透视表。然而,我发现一些聚合器和renderName对我的用户来说是不必要的。我想删除它们。例如,我想从聚合器下拉菜单中删除"Average“。
下面是我的例子:
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)我注意到似乎有一些名为"hiddenFromAggregators“的相关参数,但我不知道如何在R/Shiny环境中应用它。
这就是我找到"hiddenFromAggregators“的地方。
https://github.com/nicolaskruchten/pivottable/wiki/Parameters
发布于 2018-10-17 23:23:51
你可能正在寻找类似这样的东西:
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)可能有一种比逐个添加聚合器更快的方法(使用完整的pivotUtilities.aggregators)
我找不到默认聚合器的完整列表,但你可以在你的应用程序上使用web inspector (使用Google Chrome:右键单击> inspect),然后在控制台选项卡中输入$.pivotUtilities.aggregators。
发布于 2018-02-05 22:10:58
hiddenFromAggregators参数影响哪些数据集属性有资格用作聚合器的参数,而不是哪些聚合器可用。在rpivotTable中传入一组自定义聚合器是相当困难的,但是使用类似于这里的方法可能是可行的:https://github.com/smartinsightsfromdata/rpivotTable/issues/81
您需要首先熟悉此处的文档:https://github.com/nicolaskruchten/pivottable/wiki/Aggregators
https://stackoverflow.com/questions/48351260
复制相似问题