0

I have to use two functions in an R package and put them in a script to run the processes:

#!/usr/bin/env Rscript

library(pkg)

function1()
function2()

Both function 1 & 2 includes system() command to run some bash scripts. function2 needs the output from function1 as input.

The problem is when I run the above script in macOS or Ubuntu, both functions run at the same time so function2 would raise errors. I wonder if there's any way in R not to trigger function2 until function1 is done?

darklings
  • 3
  • 2
  • The default for `system()` is `wait=TRUE` so the first function should not return until the system call is finished. Can you provide some sort of [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) to show that's not the case? Are you sure you're not running the script more than once? – MrFlick Oct 02 '21 at 04:31
  • hmmm thanks I think you're right, I guess it's my local machine's setup is not good then the software in the first function can't even run for quite a while... I will change another machine and test my stuff again and see – darklings Oct 02 '21 at 05:06

0 Answers0