Hi > > Dear R-helpers, > > > I have got a vector which looks like the following: > > > apkz <- c(1,2,3,4,5,6,1,1,2,1,2,3,4) > > > now I am trying to find a way to automatically create several vectors, > each starting with the number 1, namely: > > > First vector > > 1 2 3 4 5 6 > > > Second vector > > 1 > > Thrid vector > > 1 2 > > Fourth vector > > 1 2 3 4 > > > Does anyone know how to do that?
This came to my mind as first, but I believe there are other options. split(apkz, cumsum(apkz==1)) Regards Petr > > > Thank you very much for your help in advance! > > > Marion > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. ______________________________________________ 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.