I am trying to schedule a task using the taskscheduleR package that uses an R script to render an R markdown html file. I keep getting an error message saying Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).
. Previous forms on stack (and here) suggest using Sys.setenv()
function right before calling the render()
function. I have tried this, and it does not seem to be working.
Here is the code I used to schedule the task:
library(taskscheduleR)
library(here)
taskscheduler_create(taskname = "test", rscript = here("script.R"), schedule= "WEEKLY", starttime = "08:00",
startdate = "11/13/2023", days = c("MON"))
And below is the contents of the "script.R" file:
file_path = "file_path_here"
Sys.setenv(RSTUDIO_PANDOC = "C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools")
rmarkdown::render("Template.rmd",
output_format = "html_document", output_file = file_path)
Whenever I try and run this task, the error log keeps having the error saying pandoc cannot be found.
For what it's worth, I am trying to access a script that is saved on my Onedrive. I am not sure if that is complicating manners.
Any assistance is greatly appreciated!