[R] Comparing proportions between groups

From: Lila86 <Lila234_at_hotmail.de>
Date: Fri, 28 Mar 2008 02:33:40 -0700 (PDT)

Hello there,

I have two groups (men and women) and I know per group how many of them smoke or don't smoke (women 40 of 200; men 100 of 300). I would like to know how I can compare in R if men and women differ significantly in their smoking. However, because there are more men in the sample than women I cannot just compare the number of smokers and non-smokers in both groups, right?! (I would not really know how to do that either, to be honest :().

I have done this:

gensmoke <- table(data$gender,data$smoke) #save table

old.digits = options("digits")        # store the number of digits
options(digits=3)                     # only print 3 decimal places
gensmokePROP = prop.table(gensmoke,1) #table of the proportions I'd like to compare
                smoker  non-smoker
women       0.200   0.800
men          0.333   0.667


But then when I try to run a t-test on it, for example

t.test(gensmokePROP[3], gensmokePROP[4], alternative = "less")

then R tells me that there are not enough observations in x. Could anyone help me? That would be really great. Thank you, Lila

-- 
View this message in context: http://www.nabble.com/Comparing-proportions-between-groups-tp16348714p16348714.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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 Fri 28 Mar 2008 - 09:41:06 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 Fri 28 Mar 2008 - 11:30:25 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