[R] Splitting vector into individual elements
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Wed Sep 15 23:05:38 CEST 2004
Paul Roebuck <roebuck at odin.mdacc.tmc.edu> writes:
> Is there a means to split a vector into its individual
> elements without going the brute-force route for arguments
> to a predefined function call?
>
> offred.rgb <- c(1, 0, 0) * 0.60;
>
> ## Brute force style
> offred.col <- rgb(offred.rgb[1],
> offred.rgb[2],
> offred.rgb[3],
> names = "offred")
> ## Desired style
> offred.col <- rgb(silver.bullet(offred.rgb),
> names = "offred")
The closest is probably this:
offred.col <- do.call("rgb", c(as.list(offred.rgb),
list(names="offred")))
(ever read/seen The Handmaid's Tale, btw?)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list