Krysta
Krysta

Reputation: 220

Limiting table to factors

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)

but this gives me SO MANY tables I bust past max.print and can't see a thing. How do I limit the tables made to certain columns or only to factors? It's doing a separate table for each value of the integer-class columns as well, which is a big reason why there are so many.

Upvotes: 2

Views: 95

Answers (1)

Greg Snow
Greg Snow

Reputation: 49660

You can determine which columns are the factors, then only pass those columns to table:

w <- sapply( data.AMIDS_, function(x) is.factor(x) )
table( data.AMIDS_d[, w] )

Upvotes: 1

Related Questions