[R] extract positive pairs
Bill.Venables at csiro.au
Bill.Venables at csiro.au
Wed Jan 28 02:16:25 CET 2009
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-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Roslina Zakaria
Sent: Wednesday, 28 January 2009 11:06 AM
To: r-help at 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 at 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.
More information about the R-help
mailing list