[R] Multiple conditional without if
Mendiburu, Felipe (CIP)
F.MENDIBURU at CGIAR.ORG
Tue Feb 27 21:42:21 CET 2007
Matthias,
According to the logic,
New matrix which is basically the old one except for all
entries which have a 4 in the 5 column AND a 1 in the 6th column
newmatrix <- oldmatrix[ (oldmatrix[,5]!=4 & oldmatrix[,6]!=1) , ]
---
newmatrix <- oldmatrix[ !(oldmatrix[,5]==4 & oldmatrix[,6]==1) , ]
by,
Felipe
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of bunny ,
lautloscrew.com
Sent: Tuesday, February 27, 2007 1:25 PM
To: r-help at stat.math.ethz.ch
Subject: [R] Multiple conditional without if
Dear all,
i am stuck with a syntax problem.
i have a matrix which has about 500 rows and 6 columns.
now i want to kick some data out.
i want create a new matrix which is basically the old one except for all
entries which have a 4 in the 5 column AND a 1 in the 6th column.
i tried the following but couldn´t get a new matrix, just some wierd
errors:
newmatrix=oldmatrix[,2][oldmatrix[,5]==4]&&oldmatrix[,2][oldmatrix[,6]
==1]
all i get is:
numeric(0)
does anybody have an idea how to fix this one ?
thx in advance
matthias
[[alternative HTML version deleted]]
More information about the R-help
mailing list