r-可下载的Plot Shiny模块在启动时会分解我的闪亮应用程序



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

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作为参数传递时,请尝试删除其后面的括号

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)

在shine中,在传递函数/反应体时,通常需要避免在对它们求值时将它们附加()。在上面的例子中,您返回的是plotInput的输出,而不是函数本身

最新更新