

To find the location of your R installation, use

#Rmarkdown guide install
Why? If the necessary packages aren’t where you tell WTS your R install is, then your script will fail, possibly silently, but definitely agonisingly. Here is a less obvious one - on Windows, you might find your R install, and your ‘win-library’ installs (packages you install in addition to base), are in different locations, and this really messes things up. We’ve dealt with one of the 4 big gotchas (location of Pandoc). If it does, (and it should, assuming you have the rmarkdown package installed, then you are good to move onto the next bit. I’m going belt and braces here - I said ‘foolproof’ remember?īefore you do anything else - once you set up your regular R script as above, source it within R itself, and make sure it renders your Rmarkdown correctly. Library ( rmarkdown ) Sys.setenv ( RSTUDIO_PANDOC = 'C:/Program Files/RStudio/bin/pandoc' ) rmarkdown :: render ( input = "Z:/Some/Folder/scheduled_report.Rmd", output_file = "Z:/Some/Folder/scheduled_report.html", output_dir = "Z:/Some/Folder" ) I recommend opening notepad or other text editor, and start logging some details
#Rmarkdown guide how to
I won’t be the only one who’s struggled with this - scheduling rmarkdown files is harder than a regular R script.Īfter a lot of trial and error, and finding little snippets from blogs, videos and forums, here is the inside scoop on what can go wrong, how to fix it, and how you too can schedule your rmarkdown scripts to run automatically with Windows Task Scheduler. …Only they aren’t, because something’s gone wrong, and you don’t know what it is. You’ve tried the Windows Task Scheduler, you’ve pointed it at your markdown file, and you’ve gone off to make some coffee safe in the knowledge that your outputs will be waiting for you when you get back to your desk… You’ve written a great rmarkdown file, and now you want to run it at a set time every day. Scheduling an Rmarkdown script can be tricky - there are a few issues that are not always obvious.
