try also this:
x <- matrix(c(2,-1,-2,3,5,6,-3,7,4,2,1,0), 4, 3)
x[!rowSums(x < 0), ]
Best,
Dimitris
farida...@gmail.com wrote:
Hello All,
I would like to remove the entire row, if there is any negative element in
that row. What is the best way to do that?
For example,
x<-matrix(c(2,-1,-2,3,5,6,-3,7,4,2,1,0), 4, 3)
the returning matrix should look like
[,1] [,2] [,3]
[1,] 2 5 4
[2,] 3 7 0
Thank you in advance,
FM
[[alternative HTML version deleted]]
______________________________________________
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.
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
______________________________________________
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.