Re: [R] Subset dataframe based on condition

From: Steve Miller <steve.miller_at_jhu.edu>
Date: Tue 18 Apr 2006 - 02:06:25 EST


How about trying a nested subset:

submydf = subset(subset(mydf, a > 1),b <= a)

Steve Miller

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Sachin J Sent: Monday, April 17, 2006 10:38 AM
To: R-help@stat.math.ethz.ch
Subject: [R] Subset dataframe based on condition

Hi,    

  I am trying to extract subset of data from my original data frame based on some condition. For example : (mydf -original data frame, submydf - subset dada frame)    

>submydf = subset(mydf, a > 1 & b <= a),
   

  here column a contains values ranging from 0.01 to 100000. I want to extract only those matching condition 1 i.e a > . But when i execute this command it is not giving me appropriate result. The subset df - submydf contains rows with 0.01 also. Please help me to resolve this problem.    

  Thanks in advance.    

  Sachin                 


        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Apr 18 02:10:16 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 18 Apr 2006 - 04:10:03 EST.

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