s-news
[Top] [All Lists]

Re: Selecting every other line from a data frame

To: "Khan, Sohail" <khan@cshl.edu>
Subject: Re: Selecting every other line from a data frame
From: Tony Plate <tplate@blackmesacapital.com>
Date: Fri, 21 Apr 2006 09:47:40 -0600
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <C8696843AE995F4EA4CDC3E2B83482A901879010@mailbox02.cshl.edu>
References: <C8696843AE995F4EA4CDC3E2B83482A901879010@mailbox02.cshl.edu>
User-agent: Mozilla Thunderbird 1.0.5 (Windows/20050711)
> d <- data.frame(x=1:10, y=LETTERS[1:10])
> seq(nrow(d))
 [1]  1  2  3  4  5  6  7  8  9 10
> d[(seq(nrow(d)) %% 2) == 1, ]
  x y
1 1 A
3 3 C
5 5 E
7 7 G
9 9 I
>

Khan, Sohail wrote:
Dear All,

I have a large data frame, from which I want to only select every other line or 
odd lines.
How can I do this?  Thanks.


Sohail Khan
Scientific Programmer
COLD SPRING HARBOR LABORATORY
Genome Research Center
500 Sunnyside Boulevard
Woodbury, NY 11797
(516)422-4076

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news



<Prev in Thread] Current Thread [Next in Thread>