2013-04-09 139 views
1

我最近在使用RShiny,並且構建了一個工作Web界面,它帶有兩個參數「日期」和「位置」,並讓我回到我們的數據庫中符合標準的一系列圖表和表格。RShiny:如何將變量從Server.R傳遞給RMD腳本

我想要做的是讓用戶能夠以HTML格式以RMD報告的形式下載所有數據和圖表。

,所以我有 1. UI.R與下載按鈕 2. Server.R的downloadHandler開始我RMD腳本 3. ????

UI.R

downloadButton('downloadData','Download') 

Server.R

output$downloadData<- downloadHandler(filename ="myData.html", 
            content= function(file= NULL){ 
            knit(thread.RMD) 
            } 
+0

你能在這裏粘貼溫斯頓的答案嗎? http://groups.google.com/group/shiny-discuss/browse_thread/thread/5e65bd574d7812d2 – 2013-04-17 19:57:36

+0

感謝您的提醒。它已被更新。 – 2013-04-17 20:04:26

回答

1

下面是我從谷歌閃亮集團得到了答案:這是給定爲https://groups.google.com/forum/?fromgroups=#!topic/shiny-discuss/XmW9V014EtI

功能downloadHandler的'content'參數需要一個選項'file'。當單擊下載按鈕時,下載處理程序會調用該函數,並使用文件參數告訴它應該在哪裏保存輸出文件。

我沒有看到一個方法來設置從knit2html()的輸出文件名,但你可以將其重命名它的創建後:

output$downloadData <- downloadHandler(
    filename ="ShinyData.html", 
    content = function(file) { 
     knit2html("myreport.rmd") 
     file.rename("myreport.html", file) 
    } 
) 

(另外,你缺少一個右括號ui.r.)

-Winston

相關問題