shinyFileSave does not save plots
Closed this issue · 2 comments
upendrak commented
I am trying to save the generated plots of a shiny app to the server side and even though I got it working for the data frames it doesn't work for plots. Here is a snippet of the code that generates the plots but doesn't save the plots to the server side.
Here is the code on the ui.R
shinySaveButton(id = 'downloadplot1', label = 'Save plot', title = "Save plot as...", filetype = "png")
And here is the relevant code in the server.R
script
observe({
volumes <- c("wd"="/Users/upendra_35/Documents/CyVerse/Images_apps/DE/VICE/Ballgown_shinyapp/")
shinyFileSave(input, "downloadplot1", roots=volumes, session=session)
fileinfo <- parseSavePath(volumes, input$downloadplot1)
if (nrow(fileinfo) > 0) {
plotMeans(gene=input$gv_var_input, gown=bg1(), as.character(fileinfo$datapath))
}
})
What I don't understand is how come it worked for saving files but not for plots?
Thanks
upendrak commented
Never mind. I figured it out..
observe({
volumes <- c("wd"="/Users/upendra_35/Documents/CyVerse/Images_apps/DE/VICE/Ballgown_shinyapp/")
shinyFileSave(input, "downloadplot1", roots=volumes, session=session)
fileinfo <- parseSavePath(volumes, input$downloadplot1)
if (nrow(fileinfo) > 0) {
ggsave(plotMeans(gene=input$gv_var_input, gown=bg1()), filename = as.character(fileinfo$datapath))
}
})