[R] Splitting vector into individual elements

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Sep 15 23:51:29 CEST 2004


Paul Roebuck <roebuck at odin.mdacc.tmc.edu> writes:

> Everyone offered 'do.call' as the solution. While that
> works, is it to say that there is no means of expanding
> the expression as an argument to the original function?

Not really. You need an explicit expansion of the argument to a list
somehow, and there's no silver bullet that can convert one function
argument to several. There are solutions without do.call, like

> offred.rgb <- c(1, 0, 0) * 0.60
> x <- quote(rgb(.,.,.,names="offred"))
> x[2:4] <- as.list(offred.rgb)
> eval(x)
   offred
"#990000"

but you might find it difficult to explain how it works a year later....


-- 
   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