s-news
[Top] [All Lists]

Re: Selecting every other line from a data frame

To: <christos@nuverabio.com>, <s-news@lists.biostat.wustl.edu>
Subject: Re: Selecting every other line from a data frame
From: "Khan, Sohail" <khan@cshl.edu>
Date: Fri, 21 Apr 2006 11:59:46 -0400
Thread-index: AcZlWqRkpU1wCVj4Qq6EZVOGlkb9rAAAIJvgAAAZIiAAADKgoA==
Thread-topic: [S] Selecting every other line from a data frame
Thanks Tony and Chritos. Its great!!

Could you recommend a good S book to learn this sort of stuff?

-Sohail

-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu]On Behalf Of Christos
Hatzis
Sent: Friday, April 21, 2006 11:53 AM
To: christos@nuverabio.com; Khan, Sohail; s-news@lists.biostat.wustl.edu
Subject: Re: [S] Selecting every other line from a data frame


Sorry it should be: 

my.df[ (1:nrow(my.df)) %% 2 == 0, ]

-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Christos Hatzis
Sent: Friday, April 21, 2006 11:51 AM
To: 'Khan, Sohail'; s-news@lists.biostat.wustl.edu
Subject: Re: [S] Selecting every other line from a data frame

You can try the following:

my.df[ nrow(my.df) %% 2 == 0, ]

for selecting even lines or == 1 for odd lines.

-Christos 

-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Khan, Sohail
Sent: Friday, April 21, 2006 11:46 AM
To: s-news@lists.biostat.wustl.edu
Subject: [S] Selecting every other line from a data frame

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



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



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