MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Selecting Rows Based on Column Values

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101512] Re: [mg101471] Selecting Rows Based on Column Values
  • From: Tomas Garza <tgarza10 at msn.com>
  • Date: Thu, 9 Jul 2009 01:55:12 -0400 (EDT)
  • References: <200907081110.HAA12236@smc.vnet.net>

The correct syntax is


 In[2]:= Select[tester=2C#[[3]]==1&]


Out[2]= {{1=2C3=2C1}=2C{4=2C2=2C1}}



You're using #[[All=2C 3]]=2C which refers to a 2d element.



Tomas




>
> I've been trying to use the Select Command to select only the rows
> that have the a specific value in a specific column. I have=2C for
> example=2C the following matrix (4x3):
>
> tester={{1=2C 3=2C 1}=2C {3=2C 1=2C 0}=2C {4=2C 2=2C 1}=2C {5=2C 6=2C 2}}
>
> I want to select the rows that have values ==1 in the 3rd column.
> I've tried:
>
> select(tester=2C #[[All=2C3]]==1&)=2C but I get an error saying that my
> request violates the matrix boundaries.
>
> The desired output should be: {{1=2C3=2C1}=2C {4=2C2=2C1}}.
>
> Any thoughts would be greatly appreciated. Thanks!
>



  • Prev by Date: Re: Selecting Rows Based on Column Values
  • Next by Date: Re: Manipulating list
  • Previous by thread: Re: Selecting Rows Based on Column Values
  • Next by thread: Re: Selecting Rows Based on Column Values