Shiny R recordPlot()在本地渲染,但对象未显示在Shinyapps.io上

Pep*_*tch 3 r shiny

我的服务器->

output$finaltable2 <- renderUI({
    if(is.null(input$check)) {return()}
    else
      tabsetPanel(
        tabPanel("Q Bins", renderPlot(replayPlot(qplot), height = 600)),
        tabPanel("P Value Histogram", renderPlot(replayPlot(tplot), height = 600)),
        tabPanel("Q Value to Use", h3(toString(qaverage)))
  )
Run Code Online (Sandbox Code Playgroud)

})

取出replayPlot()并在中调用qplot / tplot对象renderPlot()也可以:

output$finaltable2 <- renderUI({
    if(is.null(input$check)) {return()}
    else
      tabsetPanel(
        tabPanel("Q Bins", renderPlot(qplot, height = 600)),
        tabPanel("P Value Histogram", renderPlot(tplot, height = 600)),
        tabPanel("Q Value to Use", h3(toString(qaverage)))
     )
  })
Run Code Online (Sandbox Code Playgroud)

我的qplot和tplot对象是通过以下方式制作的:

plot.new() 
par(mfrow=c(3,4))
barplot(df[[1]][[2]])
   *etc, etc, etc [adding more subplots to plot]*
qplot <- recordPlot()
Run Code Online (Sandbox Code Playgroud)

也许Shinyapps Linux服务器不喜欢recordPlot()结构;有没有其他方法可以记录我的绘图数据并在output $ UI调用中呈现它?谢谢!

Pep*_*tch 5

因此,在阅读了@ginberg提供链接之后,我想到了这个答案。希望它将对2038年以后的所有读者有所帮助。

首先,在创建recordPlot()对象时,我添加了dev.control(“ enable”)和dev.off(),如下所示:

plot.new() 
dev.control("enable")
hist(df etc etc etc)
qplot <- recordPlot()
dev.off()
Run Code Online (Sandbox Code Playgroud)

然后在我的server.r文件中,在我的输出$东西renderUI中,我将renderPlot更改为包括replayPlot()。像这样:

tabPanel("Q Bins", renderPlot(replayPlot(qplot), height = 600)),
Run Code Online (Sandbox Code Playgroud)

然后,我将文件上传到Shinyapps-完美运行。感谢ginberg向我展示了有关记录和重放图形的页面。

[我尝试做的其他事情,但是与之相去甚远:]

  1. 将图另存为图像并将图像加载到tabsetPanel中。
  2. 使用plotOutput()