I checked How to execute git-bash command with system() or shell() in R but this didn't exactly solve the problem for me. I'm very new to R, I'm using it on Windows and I'm modifying another project. I suspect originally this project was written for a different OS.
At one point, the main script calls a .sh file from inside R in a for loop, and uses system() to run it. The sh file creates a new directory, copies files from one directory to the other and modifies them slightly (removes first row & adds another).
The part in the code that calls the file goes like this: (run_this is the sh file we want to run)
directory_name = "data/clean"
for (i in 1:n) {
filename = sprintf("%s.json",i)
cmd = sprintf("run_this.sh %s %s", filename, directory_name)
system(cmd)
}
I suspect system() calls command prompt in Windows, which I've checked doesn't run this sh file. But I've found I can run them from Git Bash. Unfortunately I'd have to do them one by one if I choose this option and since n is large this doesn't work very well for me.
So, I'm wondering 1) is there any way to direct system() or system2() to use Git Bash from inside R? (I have Git Bash to my environment variables.) 2) any other possible solutions to run sh files from command prompt?