0

我有shiny下面的应用程序,我想知道如何使用downloadablePlotShiny Module 下载绘图。当我启动应用程序时,整个应用程序都会崩溃。

library(shiny)
library(periscope)
ui <- fluidPage(
  plotOutput("plot"),
  downloadablePlotUI("object_id1", 
                     downloadtypes = c("png", "csv"), 
                     download_hovertext = "Download the plot and data here!",
                     height = "500px", 
                     btn_halign = "left")
)

server <- function(input, output) {
  output$plot<-renderPlot(plot(iris))
  plotInput = function() {
    plot(iris)
  }
  callModule(downloadablePlot,
             "object_id1", 
             logger = ss_userAction.Log,
             filenameroot = "mydownload1",
             aspectratio = 1.33,
             downloadfxns = list(png = plotInput()),
             visibleplot = plotInput())
  
}

shinyApp(ui = ui, server = server)
4

1 回答 1

1

plotInput在将括号作为参数传递后尝试删除括号

library(shiny)
library(periscope)
ui <- fluidPage(
  plotOutput("plot"),
  downloadablePlotUI("object_id1",
                     downloadtypes = c("png", "csv"),
                     download_hovertext = "Download the plot and data here!",
                     height = "500px",
                     btn_halign = "left")
)

server <- function(input, output) {
  output$plot<-renderPlot(plot(iris))
  plotInput = function() {
    plot(iris)
  }
  callModule(downloadablePlot,
             "object_id1",
             logger = ss_userAction.Log,
             filenameroot = "mydownload1",
             aspectratio = 1.33,
             downloadfxns = list(png = plotInput),
             visibleplot = plotInput)

}

shinyApp(ui = ui, server = server)

在闪亮的情况下,当传递函数/反应时,您通常需要避免附加它们,()因为这样做会评估它们。在上面的示例中,您返回的是 plotInput的输出而不是函数本身

于 2021-04-12T12:37:38.847 回答