Re: [R] Row percentages for a table object

From: Tom Backer Johnsen <backer_at_psych.uib.no>
Date: Thu, 07 Feb 2008 21:26:01 +0100

Tom Backer Johnsen wrote:

> Henrique Dallazuanna wrote:

>> Try this:
>>
>> prop.table(table(data), 1)
> 
> Ah.  I misunderstood Peter Dalgaard (unnskyld Peter!).  That gives what 
> I want.  Thank you!
> 
> Tom

>>
>> On 07/02/2008, Tom Backer Johnsen <backer@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.
>>>
>>
>>
>
>
-- 
+----------------------------------------------------------------+
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +47-5558-9185                        Fax : +47-5558-9879 |
| Email : backer@psych.uib.no    URL : http://www.galton.uib.no/ |
+----------------------------------------------------------------+

______________________________________________
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.
Received on Thu 07 Feb 2008 - 20:35:34 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 Thu 07 Feb 2008 - 21:30:13 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.

list of date sections of archive