Re: [R] locate the rows in a dataframe with some criteria

From: <>
Date: Sat, 08 Mar 2008 11:48:42 +1000

i <- with(M, which(x >= 10 & y == "A")) ## will get you the row indices.  

m <- subset(M, x >= 10 & y == "A") ## will get you the rows themselves

-----Original Message-----
From: [] On Behalf Of zhihuali Sent: Saturday, 8 March 2008 1:51 AM
Subject: [R] locate the rows in a dataframe with some criteria

Hi, netters,

This is probably a rookie question but I couldn't find the answer after hours of searching and trying.

Suppose there'a a dataframe M:

x y
10 A
13 B
8 A
 11 A

I want to locate the rows where x >=10 and y="A". I know how to do it to vectors by using which, but how to do it with the dataframe?

Thank you very much!

Zhihua Li

MSN 中文网,最新时尚生活资讯,白领聚集门户。

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sat 08 Mar 2008 - 01:54:13 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 Sat 08 Mar 2008 - 02:30:20 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive