【问题标题】:Download handler does not save file shiny R下载处理程序不保存文件闪亮 R
【发布时间】:2016-02-26 16:37:48
【问题描述】:
library(shiny)
library(plyr)

shinyServer(function(input, output){

  myfile<-reactive({
#reading 3 csv files and merging them into a dataframe
  })

  output$downloadData<-downloadHandler(

    filename = function(){

      paste("mergedfile","csv",sep='.')
    },

    content= function(file){
      write.csv(myfile(),file,sep=",")
    }
  )

})

我正在读取 3-4 个文件,然后合并它们。之后不显示它们,我需要下载合并的文件。

我编写了上面的代码,但打开了一个对话框,询问我在哪里保存,但文件没有保存。我的下载处理程序有问题吗?

ui.R

downloadButton('downloadData','Download')

这是我在 ui.R 文件的主面板中的内容

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    您可能使用 Rstudio 查看器来运行应用程序?在浏览器中打开应用程序,您的代码将运行 (点击在borwser中打开或运行runApp('/path/to/myApp',launch.browser=T))。

    请参阅this 链接。

    也不需要为 write.csv 设置sep=",",因为这是默认设置。

    【讨论】:

    • Oskar,这在浏览器中就像一个魅力。我永远不会猜到这一点。你的链接也很有帮助。谢谢!
    猜你喜欢
    • 2020-08-22
    • 2017-11-03
    • 2015-03-30
    • 2016-06-01
    • 2018-10-03
    • 2017-07-26
    • 1970-01-01
    • 2018-05-15
    • 2019-02-13
    相关资源
    最近更新 更多