[R] rle on large data . . . without a for loop!

Justin jtor14 at gmail.com
Sat Jun 18 01:04:22 CEST 2011


Justin Haynes <jtor14 <at> gmail.com> writes:

> 
> I think need to do something like this:
> 
> dat<-data.frame(state=sample(id=rep(1:5,each=200),1:3, 1000,
> replace=T,prob=c(0.7,0.05,0.25)),V1=runif(1,10,1000),V2=rnorm(1000))

brown bag...

dat<-data.frame(id=rep(1:5,each=200),state=sample(1:3, 1000,
replace=T),prob=c(0.7,0.05,0.25)),V1=runif(1,10,1000),V2=rnorm(1000))


> rle.dat<-rle(dat$state)
> temp<-1
> out<-data.frame(id=1:length(rle.dat$length))

snipped

> Thanks,
> 
> Justin
> 
>



More information about the R-help mailing list