[R] Counting Frequencies in Data Frame

M.Ribeiro mresendeufv at yahoo.com.br
Tue May 18 16:12:49 CEST 2010


Hi,
I am sure there is an easy way to do it, but I can't find it.
I have a data frame that has 15 columns and 7000 rows.

The only values inside the data.frame are "aa", "ab", "bb" as you can see an
example bellow.

   1  2  3
1 aa ab ab
2 ab ab ab
3 aa aa aa
4 bb bb bb

What I would like to do, is to generate a vector (or another data.frame)
with 7000 rows, and 3 columns. In the first column, the information about
how many aa, the second about how many ab, and the third about how many bb
are there in each line
  aa  ab  bb
1  1   2   0
2  0   2   0
3  3   0   0
4  0   0   3

Thank you very much
Cheers
-- 
View this message in context: http://r.789695.n4.nabble.com/Counting-Frequencies-in-Data-Frame-tp2221342p2221342.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list