[R] Vector grouping challenge

Johannes Graumann johannes_graumann at web.de
Wed Oct 28 12:57:05 CET 2009

Dear all,

Is there an efficient way to get this list
> testList <- list(c(1),c(2,3,4),c(5,6),c(7),c(8),c(9,10,11,12),c(13))

from this vector
> testVector <- c(12,32,NA,NA,56,NA,78,65,87,NA,NA,NA,90)

Basically the vector should be grouped, such that non-NA and all following 
NAs end up in one group.

Thanks for any hint,


More information about the R-help mailing list