Error in eval(predvars, data, env) : object 'CO2.f' not found when doing an Anova

Cross-posted to r - Error in eval(predvars, data, env) : object 'CO2.f' not found when doing an Anova - Stack Overflow

I'm trying to perform an repeated measurements ANOVA from my field data (field_data) with the following code:

#First convert variables into factors:
field_data$month = factor(field_data$month,

field_data$distance = factor(field_data$distance)

field_data$CO2.f = factor(field_data$CO2,
                          ordered = TRUE)
# Model
model_CO2 = clmm(CO2.f ~ month + distance + month:distance + (1|nest),
                 data = field_data,
                 threshold = "equidistant")

# Anova of the model
      type = "II")

I've run the same code for a couple of weeks without any problems, but today when I tried to run it again I got some errors: everything seems to work fine until I make the model, but when I run the Anova I get the following message:

Error in eval(predvars, data, env) : object 'CO2.f' not found

I've run:

and also tried to change the excel where I have my data, but nothing seems to work out.

Any ideas?


I've tried to run this in another computer and it seems to work fine. Does anyone have an idea why this is happening?

Update 2:

When I run the model_CO2, I get results:

Cumulative Link Mixed Model fitted with the Laplace approximation

formula: CO2.f ~ month + distance + month:distance + (1 | nest)
data:    field_data

 link  threshold   nobs logLik  AIC     niter      max.grad
 logit equidistant 123  -551.68 1137.36 1213(4936) 5.30e-04

Random effects:
 Groups Name        Variance Std.Dev.
 nest   (Intercept) 3.521    1.876   
Number of groups:  nest 5 

                    monthjuly                monthseptember                distance0.25 m 
                      -1.1232                        1.6078                        0.4056 
                distance0.5 m                distance0.75 m                   distance1 m 
                       2.5090                        0.6062                        2.5836 
     monthjuly:distance0.25 m monthseptember:distance0.25 m       monthjuly:distance0.5 m 
                       0.2939                       -0.3551                       -1.2597 
 monthseptember:distance0.5 m      monthjuly:distance0.75 m monthseptember:distance0.75 m 
                      -1.7791                        0.3966                        0.4520 
        monthjuly:distance1 m    monthseptember:distance1 m 
                      -1.4307                       -0.7867 

threshold.1     spacing 
   -3.61618     0.08347 

This is why I think it has something to do with the ANOVA and not with the factor. However, I've tried other kinds of ANOVA (to see if the problem was one library) and I keep getting the same error.

Hi @bivanezb,
Welcome to the RStudio Community Forum.

Looks like there is a problem with the columns of your data frame.
Have you checked:


Do you see what you expect?

I checked:


# In those clmm() examples, response variables are ordered factors but 
# with character labels for their levels.
# So, in your situation you *may* need

field_data$CO2.f <- factor(field_data$CO2, 


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.