Run an UNIX application within R

The R command system2() can be very useful when you want run a unix command and get the result in R.  Note that system2() is recommended instead system(). For example:

out_grep <- system2("grep", args = " -rnw '.' -e 'essai'", stdout=TRUE)

I am not sure that it is still true... it seems to work now with path in .zshrc

But if you want use a software locate in your path defined in .zshrc, it will not find it. The reason is about interactive versus login shell. You must include your path in .profile to be sure it will be available both in login and interactive shell.

system2("R", args="-e \"print('bonjour');q('no')\"")

system2("which", args="R")

system2("echo", args="$PATH")

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04