[R] need help for chi-squared test
David Winsemius
dwinsemius at comcast.net
Thu Jan 6 20:24:27 CET 2011
On Jan 6, 2011, at 1:23 PM, kiotoqq wrote:
>
> I've got a dataset which looks like this in the beginning:
>
>
> cbr dust smoking expo
> 1 0 0.20 1 5
> 2 0 0.25 1 4
> 3 0 0.25 1 8
> 4 0 0.25 1 4
> 5 0 0.25 1 4
>
> (till no. 1240, anyway, a huge set)
>
> I have to analyse cbr and smoking, I know it works with chisq.test()
> for the
> whole set, but I only need cbr and smoking, and I have no idea how to
> extract them.
This is not a sufficiently complex example on which to offer a
solution, nor is it even clear enough to understand definitively what
you want. So here is a guess:
dfrm[which(dfrm$cbr==1 & dfrm$smoking==1), ]
... which would return a dataframe (or matrix depending on what form
that data exists in) with only those cases where thos two conditions
hold. You can either assign this value to an R object or you can apply
the chisq.test() in what ever (unstated) manner you think has been
"working" to the returned value as a whole.
Please read the message at the bottom and follow its encouragement to
read the Posting Guide.
> --
> View this message in context: http://r.789695.n4.nabble.com/need-help-for-chi-squared-test-tp3177925p3177925.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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list