0

I have a project with the library targets working. But I want to call the function tar_make() from a script on an internal folder of this same project.

My folders are like this:

default2  
-> _targets.R  
-> _targets/  
    ...  
-> scripts/  
    daily_update.R  
-> R/  
    ...
-> .gitignore  
-> default2.Rproj  

So, I want to call the tar_make() inside daily_update.R, because I'm automating the execution of this entire project.

When I try to run daily_update.R with the Rscript.exe I receive this message: Error on running script

I already have my _targets.R working and I don't want to move any file from their original folder. How can I fix it?

Edumacsou
  • 15
  • 4
  • 2
    When you call `tar_make()`, your working directory needs to be the directory containing `_targets.R`. So you can either establish the working directory from inside `daily_update.R` or you can start at the project root and call `source("scripts/daily_update.R", chdir = FALSE)`. In the former case, packages `here` and `rprojroot` can help you reproducibly find the project root directory from inside a script. – landau Jun 15 '21 at 15:17
  • I will try this changes. Thanks a lot – Edumacsou Jun 15 '21 at 15:48

0 Answers0