jakob r jakob r - 1 year ago 67
Bash Question

Call shell skript with specific working directory from R

I have an sh script, that can only be run from a specific directory because it looks for the files in that directory and I don't want to change the sh file.

Suppose the file is in

and the R working directory is

What works is

wd = getwd()

But I find that rather unhandy. How can I do without changing the R working direcotry?

Answer Source

As system2 uses shQuote we can only use system() and as already pointed out by @Dirk you can then use

system("cd ./sub && sh script.sh")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download