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

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon, 30 Apr 2007 12:49:06 -0400

Try

prop.table(tab, 1)
prop.table(tab, 2)
prop.table(tab)

for the three ways of taking fractions or see ?CrossTable in the gmodels package.

On 4/30/07, lalitha viswanath <lalithaviswanath_at_yahoo.com> wrote:
> 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.
>



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 Mon 30 Apr 2007 - 16:55:10 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 Mon 30 Apr 2007 - 17:31:05 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.