Hey R users,
I have a project that I built using R studio projects which works fine from start to finish when I run it through R studio, both in my dev environment as well as production. However in the prod environment, I need it to be scheduled through the taskscheduleR
package.
Unfortunately my prod environment is a windows machine and taskscheduler
kicks off the script using Rscripts.exe
and all me .R
files which use the here
package to navigate through the project directory structure fail because the default working directory is C:/Program Files/R/R-3.4.1/bin
I thought adding a setwd(here::here())
would search for the .here
file in the location of the file that Rscripts.exe
is calling, but it doesn't. I feel really dirty to hard code a setwd()
just to get this script scheduled.
What are the best ways of handling such a situations?
Thanks in advance for your help!