[R] Odp: Creating a variable which is the sum of equal rows in a dataframe
Petr PIKAL
petr.pikal at precheza.cz
Mon May 4 13:38:55 CEST 2009
Hi
r-help-bounces at r-project.org napsal dne 04.05.2009 13:19:15:
> 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
> …
E.g.
as.data.frame(rowSums(table(test)))
Regards
Petr
>
> 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)
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list