bsmith
bsmith

Reputation: 409

R: calling a system command

I was trying to invoke an executable from within R code using the system command. If I use command line in a terminal to invoke R, and then execute system("mothur"). However, if from within an R script (on RStudio) I execute the same command, I get: sh: mothur: command not found.

In both cases, the current working directory is the same.

Do I need to invoke the command in a different manner?

thanks!

Upvotes: 1

Views: 1018

Answers (1)

Jay Achar
Jay Achar

Reputation: 1271

I'm stuggling to replicate this problem on my own system, but I think the answer would be to call which and use the output to open the application. This should work if which provides the correct path when used in the system command line:

system("$(which mothur)")

Upvotes: 0

Related Questions