Solved – Error within the dependent variable while running a RM ANOVA using ezANOVA

anovarrepeated measures

I'm having a problem running a repeated-measures ANOVA in R using the ezANOVA function.

I have data from 20 subjects – each subject participated in 2 conditions and 2 laps (80 total data points in a balanced design with no missing cells).

When I try to run the full RM ANOVA

model<-ezANOVA(data=RMdata
           ,dv=sd_speed
           ,wid=P
           ,within=c("Pr","lap")
           ,type=3)

I get the following error over and over again:

Error in ezANOVA_main(data = data, dv = dv, wid = wid, within = within,  : 
  "dv" must be numeric.

But the dv (sd_speed) is numeric!

Classes ‘grouped_df’, ‘tbl_df’, ‘tbl’ and 'data.frame': 80 obs. of  4 variables:
 $ P       : Factor w/ 20 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
     $ Pr      : Factor w/ 2 levels "control","VPA": 1 1 1 1 1 1 1 1 1 1 ...
 $ sd_speed: num  4.06 4.55 3.82 10.96 3.28 ...
     $ lap     : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
 - attr(*, "vars")=List of 1
  ..$ : symbol P
 - attr(*, "drop")= logi TRUE

I've read and tried everything and I really don't know how to fix it. It would be a pleasure if someone could help me!

Best Answer

This seems to be a bug associated with the 'tbl_df' format of your data frame. You can turn your data into a standard R data frame by using the function data.frame(). For example, right within the call to ezANOVA:

model<-ezANOVA(data=data.frame(RMdata)
       ,dv=sd_speed
       ,wid=P
       ,within=c("Pr","lap")
       ,type=3)