Generating downloadable reports

I am trying to generate the report reusing the code from https://shiny.rstudio.com/articles/generating-reports.html.
I am using Windows 10 and I get the following error:

Listening on http://127.0.0.1:3326
Warning in normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="C:\Users\edonnea\AppData\Local\Temp\RtmpAnClmt/report.Rmd": The system cannot find the file specified
Warning: Error in abs_path: The file 'C:\Users\edonnea\AppData\Local\Temp\RtmpAnClmt/report.Rmd' does not exist.
  [No stack trace available]

Is this an issue with the "/" that I see in the abs_path and how do I fix that?

You have to use relative paths in shiny. Put report.rmd inside the project directory.

Also, if you are copying report.Rmd from URL you mentioned, you have to replace the tabs with spaces.

Note that if you change the name of app.R, you have to add library(shiny)

So if the project directory is:
C:/Users/edonnea/Documents/Data Analytics/R/RANapp

and the report.Rmd file is saved in the "RANapp" folder, what should this line in the r code change to:

tempReport <- file.path(tempdir(), "report.Rmd")

My problem here is really that I don't understand what is happening with the tempdir() function, I can look this up so no problem. I have updated my code as below removing the file.copy piece and now it is working for me:

  wd <- getwd()
  tempReport <- file.path(wd, "report.Rmd")

Does it work locally but not when published to shinyapps.io?

Just leave the code on https://shiny.rstudio.com/articles/generating-reports.html exactly as it is. The app makes a copy of report.Rmd into tempdir(), you don't need to worry about where that it. I would not use getwd(). See the comment in the code.

I would add library(shiny) at the top. Make sure the report.Rmd file is saved in the root project directory.

When you publish the app to shinyapps.io, make sure you include the file report.Rmd.

Thanks, it's working fine for me now, locally and when published.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.