In my main R script, I am doing source("some/path/script1.R")
. This script includes another script in that directory:
source("script2.R")
...
Now, this will not work. The simplest solution is to use source("some/path/script2.R")
in script1.R. But that's ugly, and not robust at all - it can break if directories some/path
change. I want reasonable solution where script1.R includes script2.R irrespective of how some/path
looks like.
source()
path relative to the current script?You can use :
source("file.R", chdir = TRUE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With