> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Rui Barradas
> Sent: Monday, April 14, 2014 12:09 PM
> To: Doran, Harold; r-help@r-project.org
> Subject: Re: [R] system()
> 
> Hello,
> 
> Try instead
> 
> command <- paste(aa, fnm)
> system(command)
> 
> And read the help page for ?paste
> 
> Hope this helps,
> 
> Rui Barradas
> 
> 
> Em 14-04-2014 20:02, Doran, Harold escreveu:
> > I need to send a system command to another program from within R but
> have a small hangup
> >
> > I'm trying to do something like this
> >
> > system("notepad myfile.txt")
> >
> > But, more generally this is happening to multiple files, so I loop over
> thousands of files. For purposes of an example, my code is something like
> this, which does not work
> >
> > aa <- 'notepad.exe'
> > fnm <- 'myfile.txt'
> > system("aa fnm")
> >
> > Any suggestions?
> > Harold
> >

Harold,

you haven't said what OS you are running under, but given that your example 
program was notepad.exe I am going to guess some flavor of MS Windows.  The 
suggestion to use paste() is necessary, but it will probably not be sufficient 
to solve your problem.  The commands suggested

> command <- paste(aa, fnm)
> system(command)

freezes R on my Win 7 Pro x64 box using either 64-bit R-3.0.3 or R-3.1.0.  You 
might try switching to shell() instead of system()

> command <- paste(aa, fnm)
> shell(command)

However, it all depends on what programs you are trying to run and what 
behavior you expect.


Dan

Daniel Nordlund
Bothell, WA USA
 

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to