有没有什么方法可以将两个rCharts组合在一起,类似于gvisMerge(obj1,obj2)?我意识到rCharts对象是函数。有没有办法组合R函数?我正在使用一个shiny应用程序,想要渲染两个rCharts。
在ui.R中:
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"))
})
renderChart
只返回一个对象。你为什么要只发送一个输出,当你可以发送任意多个呢?其次,rHighcharts
的功能已经被吸收到rCharts
中,并且未来的开发将在rCharts
中进行。 - Ramnath