Re: [R] fetch uneven

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Wed, 16 Mar 2011 16:07:57 -0400

On Mar 16, 2011, at 1:21 PM, Henrik Bengtsson wrote:

> See ?seq for generating index vectors of different kinds.
>
> /Henrik
>

Most people will probably understand seq(...) better than they understand modulo arithmetic, but logical indexing could also be used for the task:

((1:12) %/% 2) == 0 # substituting length(vector) for 12

-- 
David.


> On Wed, Mar 16, 2011 at 7:43 AM, rens <piccavet@hotmail.com> wrote:
>> Hi
>> I have a vector m:
>> m
>> [1] "ABC transporters"
>> [2] "2"
>> [3] "Acetyl-CoA"
>> [4] "1"
>> [5] "Energie"
>> [6] "1"
>> [7] "FAD Biosynthese"
>> [8] "1"
>> [9] "Glyoxylate and dicarboxylate metabolism"
>> [10] "1"
>> [11] "Transport"
>> [12] "1"
>> and i want to do take the even or uneven numbers out of them
>> you can do it lik this:
>> a<-m[c(1,3,5,7,9,11)]
>>
>> but i want to do this automatic and i never now how long the vector
>> is.
>>
>> Can someone help me?
>>
>>
>> --
>> View this message in context: http://r.789695.n4.nabble.com/fetch-uneven-tp3381949p3381949.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> 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.
>>
>
> ______________________________________________
> 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.
David Winsemius, MD West Hartford, CT ______________________________________________ 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.
Received on Wed 16 Mar 2011 - 20:11:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Mar 2011 - 20:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive