bnosac / taskscheduleR

Schedule R scripts/processes with the Windows task scheduler.
331 stars 72 forks source link

running TaskscheduleR on RStudio Project #89

Closed msgoussi closed 2 years ago

msgoussi commented 2 years ago

Create a "Trial.proj" via RStudio Create Script "A.R" setwd(rstudioapi::getActiveProject()) rm(list = ls()) x <- 1:5 Create Script "B.R" source("A.R", chdir = TRUE) y <- x^2 write(y, "D:/sample_nums.txt")

can i use the package to run Script B which exists inside a project?

jwijffels commented 2 years ago

taskscheduleR is not linked to RStudio projects, you don't need RStudio to schedule R scripts with the taskscheduleR package. My preference is to use environment variables instead of rstudioapi::getActiveProject as the latter won't work when you schedule a task using the windows task scheduler. See issues https://github.com/bnosac/taskscheduleR/issues/60

You can use source, but provide the full path to a file.

msgoussi commented 2 years ago

I have read your issues #60 and i tried to edit Enviroment Variables in Windows 10 (both user variables and System variables) and i fialed to run the task. Is possible to create a dummy exmaple for explanation.?

jwijffels commented 2 years ago

I think the best place to ask these questions is stackoverflow. The issue tracker here is mainly for bugs not for how-to-do-things. Stackoverflow is the best channel there. Closing.