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

From: lalitha viswanath <lalithaviswanath_at_yahoo.com>
Date: Mon, 30 Apr 2007 09:10:24 -0700 (PDT)


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



R-help_at_stat.math.ethz.ch 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. Received on Tue 01 May 2007 - 02:10:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 May 2007 - 03:31:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.