Re: [R] writing R shell scripts?

2007-01-25 Thread Deepak Chandra
Hi All, Another newbie question. I want to write an R script that takes argument from command line and runs and produces output to stdin. You will find that difficult: did you mean stdout? My mistake -- I meant stdout :). For example if there is file foo.R with following in it.

Re: [R] writing R shell scripts?

2007-01-25 Thread Prof Brian Ripley
On Thu, 25 Jan 2007, Deepak Chandra wrote: Hi All, Another newbie question. I want to write an R script that takes argument from command line and runs and produces output to stdin. You will find that difficult: did you mean stdout? My mistake -- I meant stdout :). For example if

Re: [R] writing R shell scripts?

2007-01-25 Thread Dirk Eddelbuettel
On Thu, Jan 25, 2007 at 07:43:58PM +, Prof Brian Ripley wrote: On Thu, 25 Jan 2007, Deepak Chandra wrote: My apologies for being sketchy in my example: I was hoping to elucidate my problem without too many details. I was looking #! capabilites for running my scripts with different

[R] writing R shell scripts?

2007-01-23 Thread Deepak Chandra
Hi All, Another newbie question. I want to write an R script that takes argument from command line and runs and produces output to stdin. For example if there is file foo.R with following in it. args = commandArgs() print(args) then, when I run it like $ R foo.R hello it should print 'hello'

Re: [R] writing R shell scripts?

2007-01-23 Thread Prof Brian Ripley
On Tue, 23 Jan 2007, Deepak Chandra wrote: Hi All, Another newbie question. I want to write an R script that takes argument from command line and runs and produces output to stdin. You will find that difficult: did you mean stdout? For example if there is file foo.R with following in it.

Re: [R] writing R shell scripts?

2006-02-07 Thread FWS
Use the all powerful here document feature of bash: R --vanilla EOF # Pipe all subsequent lines into R. ### Here's my R code require(tcltk) tkmessageBox(message=It works) ## the end EOF Mike Miller wrote: I'm new to the list. I've used R and S-PLUS a bit for about 15 years but

Re: [R] writing R shell scripts?

2005-11-09 Thread Henrik Bengtsson
Mike Miller wrote: On Wed, 9 Nov 2005, Henrik Bengtsson wrote: A note of concern: When writing batch scripts like this, be explicit and use the print() statement. A counter example to compare echo 1; 2 | R --slave --no-save and echo print(1); print(2) | R --slave --no-save I

Re: [R] writing R shell scripts?

2005-11-09 Thread Na Li
On 7 Nov 2005, Mike Miller wrote: Is it possible to do this sort of thing in R using something like this?: #!/usr/lib/R/bin/R.bin Well, that isn't quite it because I tried it and it didn't work! Mike, I use a shell script to do this which also allows passing in command line options.

Re: [R] writing R shell scripts?

2005-11-09 Thread Mike Miller
On Wed, 9 Nov 2005, Henrik Bengtsson wrote: Put everything in curly brackets as my above example show. Ah ha! This leads to the latest version of my little one-liner (called doR): #!/bin/sh echo output - { $1 }; write.table(file=stdout(), .Last.value, row.names=FALSE, col.names=FALSE); q() |

Re: [R] writing R shell scripts?

2005-11-08 Thread David L. Van Brunt, Ph.D.
You can cheat by using the shell to write a small text file full of commands, then source that file by using R CMD BATCH yourtempfile.R . You can also write small text files with variables defined and values assigned, and pull them in from your script. On 11/7/05, Mike Miller [EMAIL PROTECTED]

Re: [R] writing R shell scripts?

2005-11-08 Thread Mike Miller
Many thanks for the suggestions. Here is a related question: When I do things like this... echo matrix(rnorm(25*2),c(25,2)) | R --slave --no-save ...I get the desired result except that I would like to suppress the [,1] row and column labels so that only the values go to stdout. What is the

Re: [R] writing R shell scripts?

2005-11-08 Thread Henrik Bengtsson
Mike Miller wrote: Many thanks for the suggestions. Here is a related question: When I do things like this... echo matrix(rnorm(25*2),c(25,2)) | R --slave --no-save ...I get the desired result except that I would like to suppress the [,1] row and column labels so that only the values go to

Re: [R] writing R shell scripts?

2005-11-08 Thread Mike Miller
On Wed, 9 Nov 2005, Henrik Bengtsson wrote: What you really want to do might be solved by write.table(), e.g. x - matrix(rnorm(25*2),c(25,2)); write.table(file=stdout(), x, row.names=FALSE, col.names=FALSE); Thanks. That does what I want. There is one remaining problem for my echo method.

Re: [R] writing R shell scripts?

2005-11-08 Thread Henrik Bengtsson
Mike Miller wrote: On Wed, 9 Nov 2005, Henrik Bengtsson wrote: What you really want to do might be solved by write.table(), e.g. x - matrix(rnorm(25*2),c(25,2)); write.table(file=stdout(), x, row.names=FALSE, col.names=FALSE); Thanks. That does what I want. There is one remaining

Re: [R] writing R shell scripts?

2005-11-08 Thread Mike Miller
On Wed, 9 Nov 2005, Henrik Bengtsson wrote: A note of concern: When writing batch scripts like this, be explicit and use the print() statement. A counter example to compare echo 1; 2 | R --slave --no-save and echo print(1); print(2) | R --slave --no-save I guess you are saying

Re: [R] writing R shell scripts?

2005-11-08 Thread Prof Brian Ripley
On Tue, 8 Nov 2005, Mike Miller wrote: On Wed, 9 Nov 2005, Henrik Bengtsson wrote: What you really want to do might be solved by write.table(), e.g. x - matrix(rnorm(25*2),c(25,2)); write.table(file=stdout(), x, row.names=FALSE, col.names=FALSE); Thanks. That does what I want. There is

[R] writing R shell scripts?

2005-11-07 Thread Mike Miller
I'm new to the list. I've used R and S-PLUS a bit for about 15 years but am now working to make R my main program for all numerical and statistical computing. I also use Octave for this kind of work and I recommend it (it is also under the GPL). Here's my question: In Octave I can write

Re: [R] writing R shell scripts?

2005-11-07 Thread Duncan Temple Lang
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 This has been done and I said I would integrate it into R. It is on my list of things to do relatively soon. I have never been entirely happy with the way arguments are handled and that is what has put things on hold. And now that the R startup is a