[R] Creating a variable which is the sum of equal rows in a dataframe

Cecilia Carmo cecilia.carmo at ua.pt
Mon May 4 13:19:15 CEST 2009


Hi everyone:

I need to count the number of banks of each firm in my 
data. The firm is identified by the fiscal number. The 
banks of each firm appears like this:

Firm                     Banks
500600700          Citybank
500600700          CGD
500600700          BES
500600800          Citybank
500600800          Bank1
500600900          CGD



I want to obtain the following dataframe:
Firm            numberofbanks
500600700          3
500600800          2
500600900          1



This is a question of counting the times each firm 
appears, but I don’t know which function do this. If 
anyone could help me I appreciate.

Thank you in advance for the help you could give me,

Cecilia Carmo (Portugal)




More information about the R-help mailing list