[R] Calculate the percentages of the "numbers" in every column.

Kelvin 6kelvin6 at gmail.com
Tue Jan 12 19:25:39 CET 2010


Dear friends,

I have a table like this, I have A B C D ... levels, the first column
you see is just the index, and there are different numbers in the
table.

      A  B  C  D  ...
1    0   2   1   0
2    1   0   2   1
3    2   3   0   0
4    0   0   1   0
5    0   2   3   1
...

I want to calculate the frequencies or the percentages of the numbers
in every column.

How do I get a table like this, the first column is the levels of
numbers, and the numbers inside the table are the percentages. All the
percentages should add up to 1 in every column.

      A     B      C     D   ...
  0  0.2   0.3   0.1   0.1
  1  0.1   0.1   0.2   0.1
  2  0.1   0.2   0.2   0.2
  3  0.2   0.1   0.1   0
  ...

Thanks your help!

Kelvin



More information about the R-help mailing list