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