[R] Cutting a vector
jim holtman
jholtman at gmail.com
Thu Nov 22 14:15:37 CET 2007
Here is another way of doing it:
> x <- 1:50
> split(x, as.integer(seq(0, by=1, length=length(x))/5))
$`0`
[1] 1 2 3 4 5
$`1`
[1] 6 7 8 9 10
$`2`
[1] 11 12 13 14 15
$`3`
[1] 16 17 18 19 20
$`4`
[1] 21 22 23 24 25
$`5`
[1] 26 27 28 29 30
$`6`
[1] 31 32 33 34 35
$`7`
[1] 36 37 38 39 40
$`8`
[1] 41 42 43 44 45
$`9`
[1] 46 47 48 49 50
>
On Nov 22, 2007 6:52 AM, Dani Valverde <daniel.valverde at uab.cat> wrote:
> Hello,
> I have a vector, lets say
> x <- 1:50
> I would like it to be cut at certain points, being for example 1:5,
> 6:11, 12:17, ...
> How can I do it? I have tried the cut() function, but I don not know how
> to place the cutting points properly.
> Best regards,
>
> Dani
>
> --
> Daniel Valverde Saubí
>
> Grup de Biologia Molecular de Llevats
> Facultat de Veterinària de la Universitat Autònoma de Barcelona
> Edifici V, Campus UAB
> 08193 Cerdanyola del Vallès- SPAIN
>
> Centro de Investigación Biomédica en Red
> en Bioingeniería, Biomateriales y
> Nanomedicina (CIBER-BBN)
>
> Grup d'Aplicacions Biomèdiques de la RMN
> Facultat de Biociències
> Universitat Autònoma de Barcelona
> Edifici Cs, Campus UAB
> 08193 Cerdanyola del Vallès- SPAIN
> +34 93 5814126
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help
mailing list