I\'m trying to compile a knitr script on a timer using LaunchControl (a launchd GUI for scheduling cron-like jobs on OSX).
I have a dispatcher.R script that does th
To run a .Rnw file using LaunchControl for task scheduling, create the following files in the same directory. Then, run the *.sh script in the scheduler. Voila! The problem I was encountering in my original post was the LaunchControl doesn't (by default, at least) read ~/.bash_profile, so adding the PATH variable into the .sh script resolves this.
This is any knitr
script that you can compile without issue from RStudio.
#!/Library/Frameworks/R.framework/Resources/Rscript
library("knitr")
setwd("~/some_directory")
knit2pdf("yourscript.Rnw", output = "yourscript.tex")
Make sure that you have the PATH variable to your LaTeX installation.
#! /bin/bash
PATH="/usr/texbin:${PATH}"
export PATH
Rscript yourscript_dispatcher.R
This solution works on OSX Yosemite 10.10.5 on R version 3.3.2 (2016-10-31).