Slow loop in R, any suggestion to speed it up?

Posted by cfceric on Stack Overflow See other posts from Stack Overflow or by cfceric
Published on 2012-04-15T07:06:56Z Indexed on 2012/04/15 11:28 UTC
Read the original article Hit count: 126

Filed under:

I have a data frame "m" as shown below:

m

I am trying to find each account's most active month (with most number of V1). for example for account "2", it will be "month 6", for account 3 it will be "month 1", ....

I wrote the below loop, it works fine but just takes a long time even I only used 8000 rows, the whole data set has 250,000 rows, so the code below is not usable. Does any one can suggest a better way to achieve this?

Thanks a lot.

code

© Stack Overflow or respective owner

Related posts about r