[R] yet another vectorization question

Adrian Dusa adi at roda.ro
Mon Jan 30 19:09:55 CET 2006


On Monday 30 January 2006 14:40, Philippe Grosjean wrote:
> Hello,
> Not exactly the same. By the way, why do you use do.call()? Couldn't you
> do simply:
> expand.grid(split(t(replicate(3, c(0, 1, NA))), 1:3))

Just for the sake of it, the above can be even more simple with:

expand.grid(lapply(1:3, function(x) c(0, 1, NA)))

Best,
Adrian

-- 
Adrian DUSA
Romanian Social Data Archive
1, Schitu Magureanu Bd
050025 Bucharest sector 5
Romania
Tel./Fax: +40 21 3126618 \
          +40 21 3120210 / int.101




More information about the R-help mailing list