Grouping error with lmer
<p>I have a data frame with the following structure:</p>

<pre><code>&gt; t &lt;- read.csv("combinedData.csv")[,1:7]
&gt; str(t)
'data.frame':   699 obs. of  7 variables:
 $ Awns               : int  0 0 0 0 0 0 0 0 1 0 ...
 $ Funnel             : Factor w/ 213 levels "MEL001","MEL002",..: 1 1 2 2 2 3 4 4 4 4 ...
 $ Plant              : int  1 2 1 3 8 1 1 2 3 5 ...
 $ Line               : Factor w/ 8 levels "a","b","c","cA",..: 2 2 1 1 1 3 1 1 1 1 ...
 $ X                  : int  1 2 3 4 7 8 9 10 11 12 ...
 $ ID                 : Factor w/ 699 levels "MEL_001-1b","MEL_001-2b",..: 1 2 3 4 5 6 7 8 9 10 ...
 $ BobWhite_c10082_241: int  2 2 2 2 2 2 0 2 2 0 ...
</code></pre>

<p>I want to construct a mixed effect model. I know in my data frame that the random effect I want to include (Funnel) is a factor, but it does not work:</p>

<pre><code>&gt; lmer(t$Awns ~ (1|t$Funnel) + t$BobWhite_c10082_241)
Error: couldn't evaluate grouping factor t$Funnel within model frame: try adding grouping factor to data frame explicitly if possible
</code></pre>

<p>In fact this happens whatever I want to include as a random effect e.g. Plant:</p>

<pre><code>&gt; lmer(t$Awns ~ (1|t$Plant) + t$BobWhite_c10082_241)
Error: couldn't evaluate grouping factor t$Plant within model frame: try adding grouping factor to data frame explicitly if possible
</code></pre>

<p>Why is R giving me this error? The only other answer I could google fu is that the random effect fed in wasn't a factor in the DF. But as str shows, df$Funnel certainly is.</p>