[R] yet another vectorization question
Adrian Dusa
adi at roda.ro
Mon Jan 30 16:47:53 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))
> Best,
> Philippe Grosjean
>
> Jacques VESLOT wrote:
> > this looks similar:
> > do.call(expand.grid,split(t(replicate(3,c(0,1,NA))),1:3))
Sigh, what a pity. It is indeed not the same...
So close to a one-liner though.
I come back to my original question: is it possible to modify the content of a
matrix, using apply on a different matrix?
In my original function, the slow part is:
## ...
for (k in 1:ncol(idk)) {
end.row <- start.row + nrow(tt) - 1
return.matrix[start.row:end.row, idk[ , k]] <- tt
start.row <- end.row + 1
}
## ...
I'd like to use apply on the "idk" matrix (to get rid of the for loop) and
write the contents of "tt" in the "result.matrix"...
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