[R-sig-Debian] littler usage

Dirk Eddelbuettel edd at debian.org
Sun Nov 18 04:16:25 CET 2007


On 17 November 2007 at 17:18, Dirk Eddelbuettel wrote:
| 
| On 17 November 2007 at 16:12, Sebastian P. Luque wrote:
| | 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
| 
| No different from splittin a string in R, ie strsplit and do.call("rbind")
| should do.

This should do 
	as.numeric(strsplit(arg[1], " ")[[1]]))

Dirk

| 
| 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
| | R-SIG-Debian at r-project.org
| | https://stat.ethz.ch/mailman/listinfo/r-sig-debian
| 
| -- 
| Three out of two people have difficulties with fractions.
| 
| _______________________________________________
| R-SIG-Debian mailing list
| R-SIG-Debian at r-project.org
| https://stat.ethz.ch/mailman/listinfo/r-sig-debian

-- 
Three out of two people have difficulties with fractions.



More information about the R-SIG-Debian mailing list