Skip to main content
Tweeted twitter.com/#!/StackMma/status/510851151994957824
added 21 characters in body
Source Link
RunnyKine
  • 33.3k
  • 3
  • 110
  • 176

I have a huge unbalanced panel data. I want to count number of rows within each group. For example, I have the following data:

data ={{AA,1,10},{AA,2,20},{CC,3,30},{CC,4,40},{CC,5,50},{CC,6,60},{CC,7,70},{DD,8,80}, {DD,9,90},{DD,10,100}};

data ={{AA,1,10},{AA,2,20},{CC,3,30},{CC,4,40},{CC,5,50},{CC,6,60},{CC,7,70},{DD,8,80},   
        {DD,9,90},{DD,10,100}};

I want to calculate number of rows within each group without using do loop. My result should be

result={{AA,2},{CC,5},{DD,3}};

result={{AA,2},{CC,5},{DD,3}};

Any help is greatly appreciated.

I have a huge unbalanced panel data. I want to count number of rows within each group. For example, I have the following data:

data ={{AA,1,10},{AA,2,20},{CC,3,30},{CC,4,40},{CC,5,50},{CC,6,60},{CC,7,70},{DD,8,80}, {DD,9,90},{DD,10,100}};

I want to calculate number of rows within each group without using do loop. My result should be

result={{AA,2},{CC,5},{DD,3}};

Any help is greatly appreciated.

I have a huge unbalanced panel data. I want to count number of rows within each group. For example, I have the following data:

data ={{AA,1,10},{AA,2,20},{CC,3,30},{CC,4,40},{CC,5,50},{CC,6,60},{CC,7,70},{DD,8,80},   
        {DD,9,90},{DD,10,100}};

I want to calculate number of rows within each group without using do loop. My result should be

result={{AA,2},{CC,5},{DD,3}};

Any help is greatly appreciated.

Source Link
ramesh
  • 2.3k
  • 17
  • 29

How to count number of observations/rows within each group

I have a huge unbalanced panel data. I want to count number of rows within each group. For example, I have the following data:

data ={{AA,1,10},{AA,2,20},{CC,3,30},{CC,4,40},{CC,5,50},{CC,6,60},{CC,7,70},{DD,8,80}, {DD,9,90},{DD,10,100}};

I want to calculate number of rows within each group without using do loop. My result should be

result={{AA,2},{CC,5},{DD,3}};

Any help is greatly appreciated.