R Shiny: Store the generated PDF report output from Shiny app to Dropbox -


i know how directly store pdf output (using knitr , rmarkdown) shiny app dropbox.

here code:

server.r:

shinyserver(function(input, output) {  regformula <- reactive({ as.formula(paste('mpg ~', input$x)) })  output$regplot <- renderplot({ par(mar = c(4, 4, .1, .1)) plot(regformula(), data = mtcars, pch = 19) })  #### change code here. in app, use iris.csv  #### example test if possible save file in dropbox. works #### fine. need replace iris.csv my-report.pdf  #### generated app.   observeevent(input$dropbox, { write.csv(iris,"iris.csv") drop_upload('iris.csv') })  ### end of save process ###  output$downloadreport <- downloadhandler( filename = function() {   paste('my-report', sep = '.', 'pdf') },  content = function(file) {   src <- normalizepath('report.rmd')    # temporarily switch temp dir, in case not have write   # permission current working directory   owd <- setwd(tempdir())   on.exit(setwd(owd))   file.copy(src, 'report.rmd', overwrite = true)    library(rmarkdown)   out <- render('report.rmd', pdf_document())   file.rename(out, file)  }  )  } ) 

ui.r:

shinyui( fluidpage( title = 'download pdf report', sidebarlayout(   sidebarpanel(     helptext(),     selectinput('x', 'build regression model of mpg against:',                 choices = names(mtcars)[-1]),     actionbutton("dropbox", "save in dropbox"),     downloadbutton('downloadreport')   ),   mainpanel(     plotoutput('regplot')   )   )   )    ) 

in app, used iris.csv example test if possible save file in dropbox , works fine. now, have figure out how replace iris.csv my-report.pdf generated shiny app drop box.

so ideally, user can download report in pdf clicking "download" button. if report want, can save in dropbox clicking "save" button.

does have ideas it?


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -