Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: Request for help: working with multi-level lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13681] Re: Request for help: working with multi-level lists
  • From: "David Keith" <dkeith at hevanet.com>
  • Date: Sat, 15 Aug 1998 04:39:13 -0400
  • Organization: Hevanet Communications
  • References: <6qp3mc$al3@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Try this:

<<Statistics`DescriptiveStatistics`

Mean[ Transpose[Select[list,#1[[1]]==1&]][[2]] ]

Select uses a pure function to choose those elements for which
element[[1]] ==1, Transpose transposes the list so that it is now is a
list of three lists, the 2nd of which is a list of the 2nd elements,
then [[2]] chooses just that list and Mean computes the average.
"<<Statistics`DescriptiveStatistics`" loads Mean.

Dave


KCConnolly wrote in message <6qp3mc$al3 at smc.vnet.net>...
>I have a list of 10 elements, each of which is a list of three elements
>(let's say in each case an integer, a real number, and a string). I am
>looking for the most elegant way to select those first-level elements
>(i.e., the lists) whose integer element is equal to a particular value
>(let's say "1"), and then to obtain the mean of the real number
>elements of the lists selected.  This seems as if it should be simple,
>but everything I try leads to Part specification errors.  Any help
>would be greatly appreciated.
>



  • Prev by Date: Re: linking c++ and mathematica
  • Next by Date: Problems with packages
  • Previous by thread: Re: Request for help: working with multi-level lists
  • Next by thread: Re: Request for help: working with multi-level lists