我想rCharts
根据 的选择生成多个饼图Group
,这Group
可能会根据数据框而改变。我想使用与此处类似的示例
https://gist.github.com/wch/5436415/
someDF = structure(list(Variable.Type = c("Apple", "Orange", "Banana",
"Apple", "Orange", "Banana"), Total = c(2, 1, 3, 6, 5, 4), Market = c("Pete",
"Pete", "Pete", "Sams", "Sams", "Sams")), .Names = c("Variable.Type",
"Total", "Market"), row.names = c(NA, -6L), class = "data.frame")
list = unique(someDF$Market)
在服务器.R
output$somePieCharts = renderUI({
list = unique(someDF$Group)
plot_output_list = lapply(1:length(list), function(i){
plotData = filter(someDF, Group==list[i])
chartOutput(hPlot(Total~Variable.Type, data=plotData, type='pie'))
}
)
do.call(tagList, plot_output_list)
})
在 ui.R
uiOutput('somePieCharts')