[R] It is possible to use a Shell command inside a R script?
Duncan Murdoch
murdoch at stats.uwo.ca
Fri Aug 24 14:58:11 CEST 2007
On 8/24/2007 8:05 AM, Alberto Monteiro wrote:
> Ronaldo Reis Junior wrote:
>>
>> It is possible to use a shell command inside a R script?
>>
>> I'm write a R script and I like to put somes shell commands inside
>> to R. Somethink like: convert fig01.png fig01.xpm or sed ..., etc.
>>
>> It is possible? How?
>>
> ?system
>
> BTW, I found that using things directly in R is _much_
> slower than creating a batch file and then running it.
>
> For example, I had a directory with misnamed mp3 files,
> and I wanted to use R to rename and copy them
> to another directory. I tried to use file.copy, but it
> took too much time. Writing a batch file and then running
> it was much faster.
Since you say "batch file" I assume you're on Windows. If that's the
case, then file.rename() can rename and move a file to a new directory,
as long as it's on the same drive. That should be as quick as a batch file.
Duncan Murdoch
More information about the R-help
mailing list