[R] Query about using rowSums/ColSums on table results

lalitha viswanath lalithaviswanath at yahoo.com
Mon Apr 30 18:10:24 CEST 2007


Hi
I have data of the form
class age
A      0.5
B      0.4
A      0.56666
C      0.785
D      0.535
A      0.005
C      0.015
D      0.205
A      0.605

etc etc...

I tabulated the above
as
tab <-table(data$class, cut(data$age, seq(0,0.6,0.02))

I wish to view the results in individual bins as a
percentage of the points in each bin.
So I tried
tab/colSums(tab)

However that is yielding Inf as a return value in
places where clearly the result should be a non-zero
value.

Is there an alternate way to get the results in each
bin as percentages of the total points in that
age-bin?

Thanks
Lalitha



More information about the R-help mailing list