[R-sig-Debian] littler usage

Sebastian P. Luque spluque at gmail.com
Sat Nov 24 18:10:05 CET 2007


On Sat, 24 Nov 2007 09:55:59 -0600,
Dirk Eddelbuettel <edd at debian.org> wrote:

> On 24 November 2007 at 08:47, Dirk Eddelbuettel wrote:
>> 
| On 23 November 2007 at 10:48, Sebastian P. Luque wrote:
| | Thanks Dirk for feedback on this.
>> | 
>> | I'm also trying to take two arguments from stdin and do a simple |
>> computation.  I'm looking for something like:
>> | 
>> | echo 1 10 | r -e "print(pretty(c(as.numeric(argv[1]),
>> as.numeric(argv[2]))))"
>> | 
>> | which of course doesn't work.  Any tips?
>> 
>> You have a logical inconsitency here. The string
>> 
>> echo 1 10 | r -e "print(pretty(c(as.numeric(argv[1]),
>> as.numeric(argv[2]))))"
>> 
>> go from your shell to the OS.  Who should get argv now -- echo or r ?

> Sorry, I think I am wrong here. It is not the 'compound command from
> issue' but rather the fact that r is used in a pipe.  In that case you
> need stdin processing as used below rather than argv processing.

[...]

Thanks Dirk.  I think my confusion came from the fact that I needed to do
this inside an ugly pipe, which I ended up coding as in:

somecommand ${SOMEFILE} | \
    awk '{printf "cat(diff(pretty(c(%s,%s)))[1])", $6, $7}' | r -

which of course could have been done as you described by awk'ing only the
2 numbers from SOMEFILE and do the processing inside r.  I get it now!

Thanks again,

-- 
Seb



More information about the R-SIG-Debian mailing list