Re: [R] Counter in a For Loop - Efficiency Issue

2011-02-02 Thread Bart Joosen
without a reproducible sample, it is hard to tell, but I will give it a shot. Maybe it's possible to merge your M with M2: merge(M, M2) If you only want to count times, you can use seq_along(x) in a by function eg: dat <- data.frame(person=rep(c(1,2,3), each=5), time=rnorm(15)) by(dat$person, dat$

Re: [R] Counter in a For Loop - Efficiency Issue

2011-02-02 Thread Petr Savicky
On Wed, Feb 02, 2011 at 09:35:28AM +0200, Leendert Punt wrote: > I have a 32000 x 14 matrix (M) where entry (x, y) corresponds to > person x at a discrete time y. I then have a matrix (M2) of 6 x 2 > where each entry is a an event by a person that is in the above 32000 > and at a time that is i

[R] Counter in a For Loop - Efficiency Issue

2011-02-02 Thread Leendert Punt
I have a 32000 x 14 matrix (M) where entry (x, y) corresponds to person x at a discrete time y. I then have a matrix (M2) of 6 x 2 where each entry is a an event by a person that is in the above 32000 and at a time that is in the range of the discrete time points above. I want to populate the a