On Fri, Aug 24, 2007 at 08:32:00AM -0400, Duncan Murdoch wrote:
> On 8/24/2007 6:58 AM, Ronaldo Reis Junior wrote:
> > Hi,
> > 
> > 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.
> 
> The details and available functions depend on the platform, but you want 
> to look at ?system, ?shell, and/or ?shell.exec.  (These all exist in 
> Windows; on Unix-alikes, you probably won't have the latter two.)

Don't forget pipes. 

R's ability to consistently work on connections that may be local
files, remotes files, program output, ... is a true treasure (and
thanks and credits to, I believe, Brian Ripley to make it so).

Eg you can do this 

  OD <- read.table(pipe("links -dump http://cran.r-project.org/src/contrib/ | 
awk '/tar.gz/ {print $3, $4}'"), header=FALSE, col.names=c("file", "date"))

to get files and dates of files on CRAN.   

As I recall, this also works on that other operating system, provided
you do all the legwork of installing other tools, setting PATHs etc
to provide what works out of the box on the supposedly unfriendlier OS.

Dirk

-- 
Three out of two people have difficulties with fractions.

______________________________________________
R-help@stat.math.ethz.ch 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