2015-11-24 70 views
0
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個文件,然後合併它們。之後,沒有顯示他們,我需要下載合併的文件。下載處理程序不保存文件閃亮R

我寫了上面的代碼,但打開一個對話框,詢問我在哪裏保存,但文件沒有保存。我在做下載處理程序的問題嗎?

ui.R 

downloadButton('downloadData','Download') 

這是我在我的ui.R主面板文件

回答

2

你可能使用Rstudio瀏覽器運行應用程序?在您的瀏覽器中打開應用程序,您的代碼將工作 (點擊打開borwser或運行runApp('/path/to/myApp',launch.browser=T))。

請參閱this的鏈接。

也不需要爲write.csv設置sep=",",因爲這是默認值。

+0

奧斯卡,這工作像在瀏覽器中的魅力。我從來沒有猜到過。你的鏈接也有幫助。謝謝! – codemob

+0

很高興能幫到你! –