Hi.
You folks are so clever, I thought perhaps you could help me make another
procedure more efficient.
Right now I have the following setup:
p is a vector of length m
g is a list of length n, g[[i]] is a vector whose elements are indices of p,
i.e., integers between 1 and m inclusive); the g[[i]] cover the full set
1:m, but they don't have to constitute an exact partition, theycan overlap
members.
y is another list of length n, each y[[i]] is a vector of the same length as
g[[i]].
Now I build up the vector p as follows:
p=rep(0,m)
for(i in 1:n){p[g[[i]]]=p[g[[i]]]+y[[i]]}
Can this loop be vectorized?
Thanks!
-- TMK --
212-460-5430 home
917-656-5351 cell
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.