On Thu, Apr 29, 2010 at 1:27 PM, Henrique Dallazuanna <www...@gmail.com> wrote: > Another option could be: > > split(x, replace(cumsum(is.na(x)), is.na(x), -1))[-1] >
One thing none of the solutions so far do (except I haven't tried Tal's original code) is insert an empty group between adjacent NA values, for example in: x = c(1,2,3,NA,NA,4,5,6) > split(x, replace(cumsum(is.na(x)), is.na(x), -1))[-1] $`0` [1] 1 2 3 $`2` [1] 4 5 6 Maybe this never happens in Tal's case, or it's not what he wanted anyway, but I thought I'd point it out! Barry ______________________________________________ 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.