[R] Improve code efficient with do.call, rbind and split contruction

Jun Shen jun.shen.ut at gmail.com
Fri Sep 2 19:02:49 CEST 2016


Dear list,

I have the following line of code to extract the last line of the split
data and put them back together.

do.call(rbind,lapply(split(simout.s1,simout.s1[c('SID','DOSENO')]),function(x)x[nrow(x),]))

the problem is when  have a huge dataset, it takes too long to run.
(actually it's > 3 hours and it's still running).

The dataset is pretty big. I have 200,000 unique SID and 4 DOSENO, so
totally 800,000 split dataset. Is there anyway to speed it up? Thanks.

Jun

	[[alternative HTML version deleted]]



More information about the R-help mailing list