[R] chi square test

peter dalgaard pdalgd at gmail.com
Mon Jun 17 11:07:45 CEST 2013


On Jun 17, 2013, at 10:36 , R. Michael Weylandt wrote:

> On Mon, Jun 17, 2013 at 9:14 AM, Dave Clark <dave at mailbox.co.uk> wrote:
>> I`m doing the chi square test in R, see below code:
>> 
>>> row1 <- c(27,17,13,21,80,24,35,41,18,51) #Category A (1-10) counts
>>> row2 <- c(27,11,26,13,30,28,17,30,10,21) #Category B (1-10) counts
>>> data.table <- rbind(row1,row2)
>>> data.table
>> 
>> then:
>>> chisq.test(data.table)
>> 
>> This gives me the chi figure, degrees of freedom and p value.
>> 
>> But how do I get the results of individual cells?
> 
> What do you mean 'results of individual cells'? As documented in
> ?chisq.test, you might be looking for one or more of
> 
> data.table$observed
> data.table$expected
> data.table$residuals
> data.table$stdres
> 
> Pick your poison. ;-)
> 
> MW

Replace with chisq.test(data.table)$observed, etc.


-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list