2016-07-04 84 views
0

我在使用render_site()(rmarkdown包)試圖導出兩頁網站時遇到了在R MarkDown文檔中使用Shiny輸出的問題Shiny output and R MarkDown render_site()

下面是創建我的問題的代碼塊(位於knitr或.Rmd文件之一內):

uiOutput("main") 

output$main <- renderUI({ 
    if(test$n != 0){ 
    plotOutput("mainPlot", height = test$n*length(input$yAxes)*400) 
    } 
}) 

output$mainPlot <- renderPlot({do.call("grid.arrange", c(test$plots, ncol = 1))}) 

加工時,render_site()告訴我,「輸出」對象沒有定義。單獨運行.Rmd文件可以正常運行;該問題僅在嘗試將其包含爲網站時纔會出現。 最後,當我刪除上面的行時,網站被成功創建。

輸出$ foo不被R MarkDown支持還是我缺少一些愚蠢的東西?

非常感謝你提前,

問候, 保羅


PS:我明明搜索詢問之前,我一直在努力,現在摸不着頭腦了幾個小時._。

回答

0

您是否嘗試將輸出生成代碼放入函數中?

server <- function (input, output) { 
    output$main <- renderUI({ 
    if(test$n != 0){ 
    plotOutput("mainPlot", height = test$n*length(input$yAxes)*400) 
    } 
    }) 

    output$mainPlot <- renderPlot({do.call("grid.arrange", c(test$plots, ncol = 1))}) 
}