Another option is
x[rowSums(x<0)==0, ]
but beware of floating point if your numbers can be near zero.
Regards
Petr
r-help-boun...@r-project.org napsal dne 06.01.2010 06:52:48:
> Thank you!
>
> On Jan 6, 2010 12:31am, Peter Ehlers wrote:
> > x[apply(x,1,function(x)all(x>=0)),]
>
>
>
>
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,
Thank you!
On Jan 6, 2010 12:31am, Peter Ehlers wrote:
> x[apply(x,1,function(x)all(x>=0)),]
> -Peter Ehlers
> Simon Blomberg wrote:
> x[-which(x
> but I'm sure someone will suggest an easier way.
> Simon.
> On Wed, 2010-01-06 at 05:13 +, farida...@gmail.com wrote:
> Hello A
x[apply(x,1,function(x)all(x>=0)),]
-Peter Ehlers
Simon Blomberg wrote:
x[-which(x < 0, arr.ind=TRUE)[,1],]
but I'm sure someone will suggest an easier way.
Simon.
On Wed, 2010-01-06 at 05:13 +, farida...@gmail.com wrote:
Hello All,
I would like to remove the entire row, if there is
x[-which(x < 0, arr.ind=TRUE)[,1],]
but I'm sure someone will suggest an easier way.
Simon.
On Wed, 2010-01-06 at 05:13 +, 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?
>
5 matches
Mail list logo