On 17 November 2007 at 16:12, Sebastian P. Luque wrote:
| On Sat, 17 Nov 2007 15:47:42 -0600,
| Dirk Eddelbuettel <[EMAIL PROTECTED]> wrote:
|
| [...]
|
| > You're almost there -- just use 'as.numeric' on ss too:
|
| > [EMAIL PROTECTED]:~> cat /tmp/seb.r #!/usr/bin/env r
|
| > ff <- as.numeric(argv[1])
| > ss <- as.numeric(argv[2])
| > print(ff * ss)
| > [EMAIL PROTECTED]:~> /tmp/seb.r 2 3
| > [1] 6
| > [EMAIL PROTECTED]:~>
|
| 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
No different from splittin a string in R, ie strsplit and do.call("rbind")
should do.
Gotta run, Dirk
| ,-----[ 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
|
| _______________________________________________
| R-SIG-Debian mailing list
| [email protected]
| https://stat.ethz.ch/mailman/listinfo/r-sig-debian
--
Three out of two people have difficulties with fractions.
_______________________________________________
R-SIG-Debian mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-debian