Skip to content
Back to formatted view

Raw Message

Message-ID: <20040229145712.QYHN2607.tomts25-srv.bellnexxia.net@JohnDesktop8300>
Date: 2004-02-29T14:57:13Z
From: John Fox
Subject: Proportions again
In-Reply-To: <007f01c3fed1$3a237c90$91f3fea9@quem>

Dear Carlos,

prop.table() takes a table as its argument, so you could specify
prop.table(table(sex)). See ?prop.table for more details.

John

> -----Original Message-----
> From: r-help-bounces+jfox=mcmaster.ca at stat.math.ethz.ch 
> [mailto:r-help-bounces+jfox=mcmaster.ca at stat.math.ethz.ch] On 
> Behalf Of Carlos Mauricio Cardeal Mendes
> Sent: Sunday, February 29, 2004 9:35 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Proportions again
> 
> Hello.
> 
> I asked before and it was great, cause as a beginner I 
> learned a lot. But, if I have this in R (1 and 2 are codes for sex):
> 
> > sex<-c(1,2,2,1,1,2,2,2)
> > sex
> [1] 1 2 2 1 1 2 2 2
> 
> I?d like to obtain the proportion according to sex.So I type:
> 
> > prop.table(sex)
> [1] 0.07692308 0.15384615 0.15384615 0.07692308 0.07692308 
> 0.15384615 0.15384615 [8] 0.15384615
> 
> The result is OK, but I expected to see a simple frequency 
> table or something like that:
> 
> 1   0.375
> 2   0.625
>      1.0
> 
> How can I get this ? 
>