I think this means an unequal sample in different conditions. But it seems to mean something else. . .

I have a data set like below

`particip group device width length accep thresh rating d-rating 1 RA Dingo nom nom Y 5 8 3 1 RA Dingo nom long Y 4 6 2 1 RA Dingo fat nom Y 4 6 2 1 RA Dingo fat long N 6 4 -2 `

and I'm running an ANOVA on it like so

`aov.AMIDS_d <- aov(d.rating ~ group*device*width*length + Error(particip/(device*width*length))+group,data.AMIDS_d) `

This works ok until I try to print the condition means like so

`print(model.tables(aov.AMIDS_d,"means"),digits=3) `

and it says

`Error in model.tables.aovlist(aov.AMIDS_d, "means") : design is unbalanced so cannot proceed `

According to the design, it ought to be balanced, so I need to check my data structure. I tried

`table(data.AMIDS_d[,2:5]) `

to give a table of observations per condition and got this

`, , width = fat, length = long device group Dingo SNAR NR 12 12 NV 12 12 RA 12 12 , , width = nom, length = long device group Dingo SNAR NR 12 12 NV 12 12 RA 12 12 , , width = fat, length = nom device group Dingo SNAR NR 12 12 NV 12 12 RA 12 12 , , width = nom, length = nom device group Dingo SNAR NR 12 12 NV 12 12 RA 12 12 `

which looks both correct and balanced. So what is causing the unbalanced design error?

**Contents**hide

#### Best Answer

In case anyone else has this problem, check that your all your factor columns, particularly any containing numbers and including your participant-identifier column, are classed as a Factor and not as an Integer by using str(yourdata) or class(yourdata$columnname). My particular culprit was the participants column.

If it's classed as an Integer, then

`yourdata$columnname <- as.factor(yourdata$columnname) `

will re-class it as a factor.

### Similar Posts:

- Solved – Standardized regression coefficient ($beta$) in multi-linear regression by groups
- Solved – Problem printing greyscale or B&W ggplot2 images
- Solved – Estimate specific y value in linear multiple regression using R
- Solved – Relation between R2 and the covariate correlation matrix (multidimensional case)
- Solved – Calculating Odds Ratio within Regression (in R)