r - using downloadHandler and renderPlot on a static function simultaneously -
please consider following:
# createplot takes in data, processes , generates plot using native plot() plotinput <- function(){ createplot(data=data(),name=input$name) } # render using output$plot <- renderplot({ plotinput() }, height=700,width=850,res=100) # , download pdf using output$pdflink <- downloadhandler( filename <- "plot.pdf", content <- function(file){ pdf("plot.pdf") print(plotinput()) dev.off() file.copy("plot.pdf", file) } ) createplot function has randomising factor fills in empty values small random pseudocount. so, whenever function run, points on plot not same downloaded plot bit different see on interface. can come around problem?
i've tried storing output of plotinput() static variable , re-sue variable both rendering , exporting doesn't works this.
mainplot <- plotinput()
instead of making plotinput function, try making "reactive". shiny should detect when printing file, there no need rerun reactive if none of inputs have changed, , therefore renderplot , pdf should use same plot
Comments
Post a Comment