Hello,

Thanks, and sorry for the bug.
I used what the op was using [system()] without checking if it worked. shell() worked in Windows 7/R 3.1.0.

sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252 [3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Portugal.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


Rui Barradas

Em 15-04-2014 02:26, Daniel Nordlund escreveu:
-----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.


______________________________________________
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