Neal Fultz <nfultz <at> gmail.com> writes: > > Noah, > > If N is # of rows, k is # of unique IDs > > Using which() is O(N), using which() in a loop is going to be O(Nk); > > sorting the entire data is O(N ln N) and then you can process it in > contiguous blocks, no which required. > > -Neal >
You might also take a look at the 'dplyr' package on Github: it's next-gen plyr, engineered for performance ... https://github.com/hadley/dplyr ______________________________________________ R-help@r-project.org 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.