title: lmer error: grouping factor must be < number of observations
body: <p>I am attempting to run a mixed effect model on some data but struggling with one of the fixed effects, I think primarily due to it a factor?!</p>
  
  <p>Sample data:</p>
  
  <pre><code>data4&lt;-structure(list(code = structure(1:10, .Label = c("10888", "10889", 
  "10890", "10891", "10892", "10893", "10894", "10896", "10897", 
  "10898", "10899", "10900", "10901", "10902", "10903", "10904", 
  "10905", "10906", "10907", "10908", "10909", "10910", "10914", 
  "10916", "10917", "10919", "10920", "10922", "10923", "10924", 
  "10925", "10927"), class = "factor"), speed = c(0.0296315046039244, 
  0.0366986630049636, 0.0294297725505692, 0.048316183511095, 0.0294275666501456, 
  0.199924957584131, 0.0798850288176711, 0.0445886457047146, 0.0285993712316451, 
  0.0715158276875623), meanflow = c(0.657410742496051, 0.608271363339857, 
  0.663241108786611, 0.538259450171821, 0.666299529534762, 0.507156583629893, 
  0.762448863636364, 37.6559178370787, 50.8557196935557, 31.6601587837838
  ), length = c(136, 157, 132, 140, 135, 134, 144, 149, 139, 165
  ), river = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L
  ), .Label = c("c", "f"), class = "factor")), .Names = c("code", 
  "speed", "meanflow", "length", "river"), row.names = c(2L, 4L, 
  6L, 8L, 10L, 12L, 14L, 16L, 18L, 20L), class = "data.frame")
  </code></pre>
  
  <p>My model is as such:</p>
  
  <pre><code>model1&lt;-lmer(speed ~ river + length +(1|meanflow)+(1|code), data4)
  </code></pre>
  
  <p>and when run returns error message:</p>
  
  <pre><code>Error in checkNlevels(reTrms$flist, n = n, control) : 
  number of levels of each grouping factor must be &lt; number of observations
  </code></pre>
  
  <p>Having trawled the internet I have <a href="https://stats.stackexchange.com/questions/57912">found one response</a></p>
  
  <p>but for the life of me do not understand the responses to the question!</p>