[R] Row percentages for a table object
Henrique Dallazuanna
wwwhsd at gmail.com
Thu Feb 7 20:10:37 CET 2008
Try this:
prop.table(table(data), 1)
On 07/02/2008, Tom Backer Johnsen <backer at psych.uib.no> wrote:
> I an stumbling on something that is probably very simple, but I cannot
> see the solution. I have an object generated by the table () function
> and want to recompute this table so each cell represents the
> percentage of the corresponding row sum.
>
> Of course a dedicated function can be written (which I have done),
> containing the necessary loops etc., but there should be a simpler
> way. I'd prefer something simple and as transparent as possible since
> it is for use in a text I am writing for my students. I have fiddled
> around with the apply () function but have so far been unable to find
> something that works.
>
> Any suggestions?
>
> Tom
>
> ______________________________________________
> R-help at r-project.org 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.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
More information about the R-help
mailing list