我正在使用 R闪亮,想在 gridExtra 的帮助下并排放置几个 ggplotly 图。
一张图(没有 gridExtra)效果很好:
library(shiny)
library(plotly)
u <- fluidPage(plotlyOutput(outputId = "myplots"))
s <- function(input, output) {
pt1 <- reactive({
ggplotly(qplot(42))
})
output$myplots <- renderPlotly({
pt1()
})
}
shinyApp(u, s)
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试通过 gridExtra 添加另一幅图时,它拒绝工作:
library(shiny)
library(plotly)
library(gridExtra)
u <- fluidPage(plotlyOutput(
outputId = "myplots"
))
s <- function(input, output){
pt1 <- reactive({
ggplotly(qplot(42))
})
pt2 <- reactive({
ggplotly(qplot(57))
})
output$myplots <- renderPlotly({
grid.arrange(pt1(), pt2(),
widths = c(1, 1),
ncol = 2)
})
}
shinyApp(u, s)
Run Code Online (Sandbox Code Playgroud)
给我
gList 中的错误:“gList”中仅允许“grobs”