I'm assuming the column names really are X1 and X2, literally.  If so, why not

y1y2_dash <- subset(y1y2, X1 > 0 & X2 > 0)

?

Note: Here you need '&', not '&&'.

Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-----Original Message-----
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Roslina Zakaria
Sent: Wednesday, 28 January 2009 11:06 AM
To: r-help@r-project.org
Subject: [R] extract positive pairs

Hi,

I have a data below and would like to search for positive pairs only and form a 
new data set.
           X1             X2
31.0 9.0 
11.0 1.0 
1.0 0.0 
0.0 0.0 
8.0 0.0 
0.0 0.0 
2.0 2.0 
18.0 3.0 
0.0 0.0 
0.0 0.0 
0.0 0.0 
10.0 0.0 
6.0 0.0 
...

The new data will be 

X1'   X2'
31.0 9.0 
11.0 1.0 
2.0 2.0 
18.0 3.0 

I tried to write the function as:

y1y2 <-  read.csv("genX1X2.csv", header=FALSE)
(y1y2[,1] > 0 )  &&  (y1y2[,2]>0)
cbind(y1y2[,1],y1y2[,2])
 
Thank you for your help.




______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to