我有一個Shiny應用程序和一個R腳本,我想嵌入到我的Shiny應用程序中。該腳本輸出一個ggplot
,我不知道如何讓它出現在我的Shiny App中。我已經排除了一些無關的代碼。該腳本已成功調用,並且變量存儲在我的工作區中,但不顯示任何內容。如何使用source()以閃亮的方式顯示ggplot輸出?
我已經列入我server.R
文件中的以下內容:
##server.R##
source("heatmap.R", local=TRUE)
output$heatmap <- renderPlot ({
heatmapOutput
})
##ui.R##
shinyUI(fluidPage(
column(10, plotOutput("heatmap"))
),
你嘗試保存ggplot給一個變量,並把它傳遞給渲染圖功能? –
如果我將圖保存到'heatmap.R'中的'heatmapOutput',並像修改後的代碼中那樣調用它,那會起作用嗎? – Gary
我會在'heatmap.R「裏放置'output $ heatmap < - renderPlot({你所有的代碼都是製作heatmapOutput})'。然後,就像你在服務器上的源一樣,並且不需要重寫'output $ heatmap < - ...' – jenesaisquoi