MathGroup Archive 2006

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

Search the Archive

Re: Count Function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65526] Re: Count Function
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Thu, 6 Apr 2006 06:52:31 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <e1091t$ljd$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Gregory Lypny wrote:
> The syntax will be the death of me.
> 
> Count[X[[All,14]], -9.] will tally how many elements in column 14 of  
> matrix X are equal to -9, but I can't for the life of me figure out  
> how to get how many are greater than -9.  Any hint would be most  
> appreciated.
> 
> 	Greg
> 
> 
Hi Greg,

Here is an example with a 20 by 2 matrix:

In[1]:=
data = Table[{n, Random[Integer, {1, 15}]}, {n, 20}]

Out[1]=
{{1, 15}, {2, 10}, {3, 15}, {4, 5}, {5, 8}, {6, 13},
   {7, 4}, {8, 3}, {9, 1}, {10, 3}, {11, 6}, {12, 10},
   {13, 2}, {14, 15}, {15, 13}, {16, 4}, {17, 1},
   {18, 4}, {19, 9}, {20, 12}}

In[2]:=
Count[data[[All,2]], _?(#1 > 9 & )]

Out[2]=
8

Hope this helps,
Jean-Marc


  • Prev by Date: Re: Count Function
  • Next by Date: Re: Two independent y axes ?
  • Previous by thread: Re: Count Function
  • Next by thread: Re: Count Function