[R] Subset dataframe based on condition

Steve Miller steve.miller at jhu.edu
Mon Apr 17 18:06:25 CEST 2006


How about trying a nested subset:

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

Steve Miller

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Sachin J
Sent: Monday, April 17, 2006 10:38 AM
To: R-help at 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 at 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




More information about the R-help mailing list