Skip to content
Prev 178247 / 398506 Next

use of "input" in system()

On Fri, 24 Apr 2009, Mike Miller wrote:

            
I still can't figure that out, but it is OK because I found a better way. 
For some reason I was thinking of the system function like this...

system( "command" )

...when I could have been thinking of it like this:

foo <- "command"

system( foo )

Maybe obvious in retrospect, but that makes it much easier to take values 
from R and insert them into system commands.  Here is a mini example:
[1] "touch file0005.out"

Thus I have placed two system commands into variables foo and bar.  The 
system commands can be pasted together using " ; " as a separator...
[1] "touch file0005.out ; ls"


...then executed like so:
Mike

Michael B. Miller, Ph.D.
Minnesota Center for Twin and Family Research
Department of Psychology
University of Minnesota