MathGroup Archive 2006

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

Search the Archive

Re: Count Function


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