开发者

1-way anova in R help

I am new in R (statistic packet) programming and I would like to make an 1way anova.

My frame of data is like that

     q1 sex
1    N   M
2    Y   F
3    U   F
   ...
1000 Y   M
开发者_Go百科

Could you help me please ?


Following up on @Thilo's and @DWin's comments above: if you really want to analyze the relationship between two categorical variables, you might try something like this:

## make up random data (no real pattern)
dat <- data.frame(q1=sample(c("N","Y","U"),size=1000,replace=TRUE),
                  sex=sample(c("M","F"),size=1000,replace=TRUE))
dtab <- with(dat,table(q1,sex))
chisq.test(dtab)
mosaicplot(dtab)

It would be really helpful from the point of view of answering your questions to have some more context: what question are you trying to answer? Also, as always, it's nice to have a reproducible example (just to save the time of coming up with my own way of generating some fake data to play with).

One small point is that the Pearson chi-square test is testing for association; it doesn't distinguish between response and predictor variables as the ANOVA framework does.

Of course, if you really have a continuous response variable that you're neglecting to tell us about, then this won't be too useful ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜