Hi, May be this helps: rle(try)$values #[1] 1 2 3 1 2 4
#or aggregate(try,list(cumsum(c(1,abs(diff(try))))),unique)[,2] #[1] 1 2 3 1 2 4 #or res<-tapply(try,cumsum(c(1,abs(diff(try)))),head,1) attr(res,"dimnames")<-NULL res #[1] 1 2 3 1 2 4 A.K. I am trying to delete repeated values in an array. try <- c(1,1,1,1,1,2,2,2,3,3,3,1,1,1,2,2,4,4,4) what I want back is: 1 2 3 1 2 4 so unique() doesn't work for my purposes as it would give me: 1 2 3 4 ______________________________________________ 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.