[R] Odp: Cutting a vector

Petr PIKAL petr.pikal at precheza.cz
Thu Nov 22 13:13:43 CET 2007


Hi

you shall be more specific. Do you want to split your vector according 
some pionts

split(x, findInterval(x, c(6,12,16)))

if you want to make a factor from your x vector, then you can use 
findInterval or cut

cut(x, breaks = c(0,6,12,17, +Inf))

Or something else?
Regards

Petr
petr.pikal at precheza.cz

r-help-bounces at r-project.org napsal dne 22.11.2007 12:52:38:

> 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.



More information about the R-help mailing list