Thank you very much for your help! I used the
split(apkz, cumsum(apkz==1)) command and it worked! I find the command very interesting and after a bit of thinking I found out, why the command cusum is used! (Because TRUE equals 1 and FALSE equals 0) Thanks again! Marion 2012/2/6 Petr PIKAL <petr.pi...@precheza.cz> > 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. > > [[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.