Re: Help! Delete Casses based on column

• To: mathgroup at smc.vnet.net
• Subject: [mg58301] Re: Help! Delete Casses based on column
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Sun, 26 Jun 2005 23:13:04 -0400 (EDT)
• Organization: The Open University, Milton Keynes, England
• References: <d9lfee\$13q\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```tornado78 wrote:
> Any help would be apreciated
>
> I need to take a large numeric matrix and remove all the rows that have a value less than X in column N
>
> Since its a large matrix im looking for an efficient algorithm.
>
> thanks
>

If I have understood correctly what you wanted, the following function
should helps.

In[1]:=
removeRow[inmatrix_, forvalue_, incol_] :=
Module[{m = inmatrix, X = forvalue, N = incol},
m[[Complement[Range[Length[m]],
Flatten[Position[m[[All,N]], _?(#1 < X & )]]]]]]

In[2]:=
mat = Table[Table[Random[], {1000}], {10000}];

In[3]:=
Timing[newmat = removeRow[mat, 0.217193, 37]; ]

Out[3]=
{0.10899999999999999*Second, Null}

In[4]:=
{Dimensions[mat], Dimensions[newmat]}

Out[4]=
{{10000, 1000}, {7753, 1000}}

Tested on a Pentium IV 2.6GHz 512Mo Physical Ram, Windows XP SP2,
Mathematica 5.1.

Best regards,
/J.M.

```

• Prev by Date: Re: Help! Delete Casses based on column
• Next by Date: Re: Help! Delete Casses based on column
• Previous by thread: Re: Help! Delete Casses based on column
• Next by thread: Re: Help! Delete Casses based on column