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
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
>
>
> S
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
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 ve
4 matches
Mail list logo