[R-sig-Debian] littler usage

Sebastian P. Luque spluque at gmail.com
Sat Nov 17 23:12:17 CET 2007


On Sat, 17 Nov 2007 15:47:42 -0600,
Dirk Eddelbuettel <edd at debian.org> wrote:

[...]

> You're almost there -- just use 'as.numeric' on ss too:

> edd at ron:~> cat /tmp/seb.r #!/usr/bin/env r

> ff <- as.numeric(argv[1])
> ss <- as.numeric(argv[2])
> print(ff * ss)
> edd at ron:~> /tmp/seb.r 2 3
> [1] 6
> edd at ron:~>

Thanks Dirk!  However, I'm trying to pass several numbers as a single
argument, which should be turned into a numeric vector, and doing
as.numeric() fails:

$ r littler_ex.R 14 '3, 2'
[1] NA

,-----[ cat ~/scripts/R/littler_ex.R ]
| ff <- as.numeric(argv[1])
| ss <- as.numeric(argv[2])
| print(ff * ss)
`-----

I know I could simply pass each number as a separate arg, but I already
have 6 args to handle.  I didn't find an example for this situation in the
examples.  Thanks.


-- 
Seb



More information about the R-SIG-Debian mailing list