Re: CategoryCounts

• To: mathgroup at smc.vnet.net
• Subject: [mg61442] Re: [mg61403] CategoryCounts
• From: "Carl K. Woll" <carl at woll2woll.com>
• Date: Wed, 19 Oct 2005 02:16:35 -0400 (EDT)
• References: <200510180644.CAA11223@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Gregory Lypny wrote:
> Hello Everyone,
>
>     I'm having trouble with the bivariate form of CategoryCounts.
>
> I have an 1000 x 11 array named h1 whose 9th and 11th columns contain
> the month and year, such as
>
> h1[[All, {9,11}]={{October, 1999}, {October, 1999}, {October, 1999},
> {August, 1999}, {August, 1999},...}
>
> Picking off months is no problem because
> CategoryCounts[h1[[All, 9]], {"October", "July", "August"}]
> correctly gives me {38, 752, 210}.
>
> And picking off years is also no problem because
> CategoryCounts[h1[[All, 11]], {1999, 2000, 2001, 2002, 2003}]
> correctly gives me {1000, 0, 0, 0, 0} (the first 1,000 observations
> all occurred in 1999).
>
> But picking off months and years does not give me the 3 x 5 array
> that I expect:
> CategoryCounts[h1[[All, {9,11}]], {{"October", "July", "August"},
> {1999, 2000, 2001, 2002, 2003}}]
> yields {0, 0}.
>
>     What am I doing wrong?  Any advice would be most appreciated.
>
>         Greg
>

Your syntax is a bit off. In your example you should use:

CategoryCounts[
h1[[All, {9,11}]],
{{"October"},{"July"},{"August"}},
{{1999},{2000},{2001},{2002},{2003}}
]

Specifically, you should have 3 arguments to CategoryCounts, not 2 as in