Message-ID: <B998A44C8986644EA8029CFE6396A9240100CBA2@exqld2-bne.nexus.csiro.au>
Date: 2008-03-08T01:48:42Z
From: Bill Venables
Subject: locate the rows in a dataframe with some criteria
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: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of zhihuali
Sent: Saturday, 8 March 2008 1:51 AM
To: r-help at stat.math.ethz.ch
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]]