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.
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
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
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'
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.
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
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
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.
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() |
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]
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
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
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.
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
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
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
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
-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
18 matches
Mail list logo