ShinyFileSave不保存绘图

时间:2018-11-07 01:07:28

标签: r shiny shinydashboard

我正在尝试将生成的闪亮应用程序的图保存到服务器端,即使我将其用于数据框架也无法将其用于图。这是生成图表但未将图表保存到服务器端的代码片段。

这是ui.R上的代码

shinySaveButton(id = 'downloadplot1', label =  'Save plot', title = "Save plot as...", filetype = "png")

这是server.R脚本中的相关代码

observe({
    volumes <- c("wd"="/Users/upendra_35/Documents/CyVerse/Images_apps/DE/VICE/Ballgown_shinyapp/")
    shinyFileSave(input, "downloadplot1", roots=volumes, session=session)
    fileinfo <- parseSavePath(volumes, input$downloadplot1)
    if (nrow(fileinfo) > 0) {
      plotMeans(gene=input$gv_var_input, gown=bg1(), as.character(fileinfo$datapath))
    }
  })

如果需要查看整个代码,请告诉我。

1 个答案:

答案 0 :(得分:0)

没关系。我想到了。这是它的工作方式。

observe({
    volumes <- c("wd"="/Users/upendra_35/Documents/CyVerse/Images_apps/DE/VICE/Ballgown_shinyapp/")
    shinyFileSave(input, "downloadplot1", roots=volumes, session=session)
    fileinfo <- parseSavePath(volumes, input$downloadplot1)
    if (nrow(fileinfo) > 0) {
      ggsave(plotMeans(gene=input$gv_var_input, gown=bg1()), filename = as.character(fileinfo$datapath))
    }
  })