[R] Deleting rows or cols that do not meet cut off

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Tue Apr 21 23:45:25 CEST 2009


Wacek Kusnierczyk wrote:
> Rolf Turner wrote:
>   
>>
>> d[apply(d,1,function(x){any(x<=1)}),apply(d,2,function(x){any(x<=1)})]
>>     
>
> ... or gain a bit on performance by doing the threshold comparison on
> the whole matrix just once at once:
>
>     dd = d <= 1
>     d[apply(d, 1, any), apply(d, 2, any)]
>   

of course,

    dd = d <= 1
    d[apply(dd, 1, any), apply(dd, 2, any)]

vQ




More information about the R-help mailing list