[R] help required state wise count

Jim Lemon jim at bitwrit.com.au
Mon May 24 12:31:22 CEST 2010


On 05/24/2010 07:44 PM, Mohan L wrote:
> I have the data like this:
>
>> dummy
>     State Months No
> 1    xxx    Jan  1
> 2    xxx    Jan  2
> 3    xxx    Jan  1
> 4    yyy    Jan  1
> 5    yyy    Jan  2
> 6    yyy    Jan  1
> 7    zzz    Jan  3
> 8    zzz    Jan  1
> 9    zzz    Jan  2
> 10   xxx    Feb  3
> 11   xxx    Feb  4
> 12   xxx    Feb  2
> 13   yyy    Feb  1
> 14   yyy    Feb  2
> 15   yyy    Feb  1
> 16   zzz    Feb  2
> 17   zzz    Feb  3
> 18   zzz    Feb  3
>
> I want for a month Jan how many count(row) is there for xxx and yyy.some
> thing like this:
>
> State Jan  Feb  Mar
> xxx   3     3
> yyy   3     3
> zzz   3     3
>
Hi Mohan,
Try this:

table(dummy$State,dummy$Months)

Jim



More information about the R-help mailing list