MathGroup Archive 2009

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

Search the Archive

Re: Counting Categories


Thank you, Darren.  I guess my only other question would be how to  
sort either the original data or the output so that it has the same  
ordering as the choices {red, blue, green}, {small, medium, big}.

Regards,

	Gregory

On Wed, Feb 25, 2009, at 10:50 AM, Darren Glosemeyer wrote:

> You mentioned Cases, but I think you meant Count. Tally will do the  
> counting you described.
>
> In[1]:= data = Transpose[{RandomChoice[{red, blue, green}, 20],
>          RandomChoice[{small, medium, big}, 20]}];
>
> In[2]:= Tally[data]
>
> Out[2]= {{{blue, medium}, 6}, {{green, medium}, 2}, {{red, medium},  
> 2}, {{green, small}, 5},
> >    {{blue, small}, 1}, {{red, small}, 2}, {{red, big}, 2}}
>
>
> Darren Glosemeyer
> Wolfram Research



  • Prev by Date: Re: Creating TOC with Mathematica 7
  • Next by Date: Re: Inverse of a Big Matrix
  • Previous by thread: Counting Categories
  • Next by thread: Re: Counting Categories