[R] creating more vectors out of one

Paul Hiemstra paul.hiemstra at knmi.nl
Mon Feb 6 12:22:22 CET 2012


Hi,

This piece of R code does the trick:

do.call("c", sapply(c(6,1,2,4), seq, from = 1))

regards,
Paul

On 02/06/2012 11:15 AM, Marion Wenty wrote:
> 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?
>
>
> Thank you very much for your help in advance!
>
>
> Marion
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.


-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770



More information about the R-help mailing list