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: [mg101519] Re: [mg101471] Selecting Rows Based on Column Values
  • From: Syd Geraghty <sydgeraghty at me.com>
  • Date: Thu, 9 Jul 2009 01:56:32 -0400 (EDT)
  • References: <200907081110.HAA12236@smc.vnet.net>

Cynthia,

tester = {{1, 3, 1}, {3, 1, 0}, {4, 2, 1}, {5, 6, 2}}

Select[tester, #[[3]] == 1 &]

{{1, 3, 1}, {4, 2, 1}}

Cheers ... Syd

Syd Geraghty B.Sc, M.Sc.

sydgeraghty at mac.com

Mathematica 7.0.1 for Mac OS X x86 (64 - bit) (18th February 2009)
MacOS X V 10.5.6
MacBook Pro 2.33 GHz Intel Core 2 Duo  2GB RAM





On Jul 8, 2009, at 4:10 AM, cynthia wu wrote:

> 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, for
> example, the following matrix (4x3):
>
> tester={{1, 3, 1}, {3, 1, 0}, {4, 2, 1}, {5, 6, 2}}
>
> I want to select the rows that have values ==1 in the 3rd column.
> I've tried:
>
> select(tester, #[[All,3]]==1&), but I get an error saying that my
> request violates the matrix boundaries.
>
> The desired output should be: {{1,3,1}, {4,2,1}}.
>
> Any thoughts would be greatly appreciated.  Thanks!
>



  • Prev by Date: 2dFFT & image processing
  • 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