MathGroup Archive 2002

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

Search the Archive

RE: Data manipulation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37706] RE: [mg37674] Data manipulation
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 9 Nov 2002 00:29:13 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Adam,

You just need Select with a pure function.

data = {{0.39501, 10}, {1.65689, 20}, {2.40239, 30}, 
   {3.27252, 40}, {4.41738, 50}};

Select[data, 2.0 <= First[#] < 4 &]
{{2.40239, 30}, {3.27252, 40}}

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/ 

From: Adam Smith [mailto:adam.smith at hillsdale.edu]
To: mathgroup at smc.vnet.net


I know that this has been covered before, but I could not find it.

I have a list of data and I want to select a subset based on a
condition.

A simple example:

data = 
{{0.39501, 10}, {1.65689, 20}, {2.40239, 30}, {3.27252, 40}, {4.41738,
50}}

I want to select only the pairs for which the first element of each
pair is greater than or equal to 2.0 and less than 4.0  In this case
the final result would be

{{2.40239, 30}, {3.27252, 40}}

In reality the list is several hundred pairs.

Thanks

Adam



  • Prev by Date: How to use error message return values
  • Next by Date: Re: problem
  • Previous by thread: Re: Data manipulation
  • Next by thread: SetDirectory and memory management