MathGroup Archive 2012

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

Search the Archive

Re: select 1st column element based on criteria in 2nd column in mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124196] Re: select 1st column element based on criteria in 2nd column in mathematica
  • From: "Oleksandr Rasputinov" <oleksandr_rasputinov at hmamail.com>
  • Date: Thu, 12 Jan 2012 04:21:45 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

Or maybe:

Pick[#1, Thread[#2 > 3]] & @@ Transpose[pairs]

On Wed, 11 Jan 2012 22:25:16 -0000, Murray Eisenberg  
<murray at math.umass.edu> wrote:

> You cannot directly select from a "table", as there is no such object in
> Mathematica. You want to select from a list of 2-element lists. (You may
> _display_ such a list of lists in Table form, but such a display is not
> an object upon which you'd want to operate.)
>
> So do it like this (among other ways):
>
>   pairs = {{1,3}, {2,4}, {3,6}, {4,1}, {5,3}, {6,2}, {7,5}, {8,2}};
>   First /@ Select[pairs, Last[#] > 3 &]
>
> The Select function pulls out those pairs that satisfy your condition;
> the condition is specified by the "pure function" that's the 2nd
> argument to Select. Finally, mapping First (First /@ ...) onto the
> result gives the first member of each pair selected.
>
> On 1/11/12 4:18 AM, Hani wrote:
>> hello, I have a question.
>>
>> Suppose I have a table with two columns like this:
>>
>> 1  3
>> 2  4
>> 3  6
>> 4  1
>> 5  3
>> 6  2
>> 7  5
>> 8  2
>>
>> I want to select elements of the 1st column which its corresponding 2nd
>> column elements are bigger than 3. so, the result should be {2,3,7}.   
>> How to
>> implement that in mathematica? Thanx a lot



  • Prev by Date: Re: Unit testing using imported data
  • Next by Date: Re: take square of the second and third column of a table
  • Previous by thread: Re: select 1st column element based on criteria in 2nd column in mathematica
  • Next by thread: Is it possible to flatten hash table?