无论如何,我可以组合两个 rCharts,比如 gvisMerge(obj1, obj2)。我意识到 rCharts 对象是函数。有什么方法可以组合 R 函数。我正在使用一个闪亮的应用程序,我想在其中呈现两个 rCharts。
output$chart = renderChart({
a <- rHighcharts:::Chart$new()
a$title(text = "Report 1")
a$xAxis(categories = as.character(df1$Date))
a$yAxis(title = list(text = "Report 1"))
a$data(x = df1$Date, y = df1$Val1, type = "line", name = "Values 1")
a$data(x = df1$Date, y = df1$Val2, type = "column", name = "Values 2")
a
b <- rHighcharts:::Chart$new()
b$title(text = "Report 2")
b$xAxis(categories = as.character(df2$Week))
b$yAxis(title = list(text = "Report 2"))
b$data(x = df2$Week, y = df2$Val3, type = "line", name = "Values 3")
b$data(x = df2$Week, y = df2$Val4, type = "column", name = "Values 4")
b
return(a,b) # Can we combine both and return
})
在 ui.R
output$mytabs = renderUI({
tabs = tabsetPanel(
tabPanel('Plots', h4("Plots"), chartOutput("chart"))
})