0
Я пытаюсь загрузить файл без ggplot в Shiny. Я могу видеть сюжет в приложении, но когда я нажимаю кнопку plotDownload в пользовательском интерфейсе, он загружает ПОСТОЯННЫЙ PNG-файл. Кто-то может понять, что я делаю неправильно?Сохранение PNG-графика не-ggplot в Shiny
server.R
library(shiny)
shinyServer(
function(input, output) {
plotInput <- reactive({
plot(rnorm(sample(100:1000,1)))
})
output$pngPlot <- renderPlot({ plotInput() })
output$downloadPlot <- downloadHandler(
filename = "myPlot.png",
content = function(file){
png(file, width=800, res=100)
print(plotInput())
dev.off()
})
}
)
ui.R
require(shiny)
pageWithSidebar(
headerPanel("Output to png"),
sidebarPanel(
downloadButton('downloadPlot')
),
mainPanel({ mainPanel(plotOutput("pngPlot")) })
)
Thnks.