[R] two sample chi-squared test
David Winsemius
dwinsemius at comcast.net
Fri Jan 29 17:43:58 CET 2010
On Jan 29, 2010, at 11:11 AM, eric lee wrote:
> Hello,
>
> Can you tell me what R function to use to do a two-sample chi-squared
> test? I want to see if two distributions are significantly different
> from each other, and I don't specify the theoretical distribution of
> either. For example, I have the following fake count data:
>
> x <- sample(1:10,50,replace=TRUE)
> y <- sample(1:10,100,replace=TRUE)
>
> I saw chisq.test in the stats package, but that looks like a
> one-sample test.
Nope. You do need to supply it with the right organization of data,
though. In your case that would be a 2 x 10 or a 10 x 2 matrix (so
(2-1)x(10-1)=9 d.f)
?table
?matrix
> I'm running version 2.7.2 on windows xp.
Probably has very little bearing on this problem, but that is
considered to be badly outdated in 2010.
> Thanks.
--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list