Roy Mathew wrote:
Thanks for the reply Erik, As you mentioned, grouping consecutive elements of 'a' was my idea. I am unaware of any R'ish way to do it. It would be nice if someone in the community knows this.
Is this the idea you're trying to execute? It uses ?rle and ?mapply. a <- c(2,3,5,5,5,6,6,7) mapply(rep, "hello", rle(a)$lengths, USE.NAMES = FALSE) [[1]] [1] "hello" [[2]] [1] "hello" [[3]] [1] "hello" "hello" "hello" [[4]] [1] "hello" "hello" [[5]] [1] "hello" ______________________________________________ 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.