[R] Odp: Cutting a vector
Dani Valverde
daniel.valverde at uab.cat
Thu Nov 22 15:44:33 CET 2007
Hello,
That's very useful. I think the cut() function is the key. However, in
my real vector I have 13112 points. I would like the function to cut the
vector every certain number of points (ie 4). Is there a way to specify
this without the need of writing each cutting point? For example, I do
not want to write breaks=c(4,8,12,...,13108, +Inf), but some expresion
to avoid writing such a long argument.
Best regards,
Dani
En/na Petr PIKAL ha escrit:
> 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.
>>
>
>
>
--
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
More information about the R-help
mailing list