title: R Warning: newdata' had 15 rows but variables found have 22 rows
body: <p>I have read few answers on this here but I am afraid I have not been able to figure out an answer.</p>
  
  <p>My R code is:</p>
  
  <pre><code>colors &lt;- bmw[bmw$Channel=="Colors" &amp; bmw$Hour=20,]
  colors_test &lt;- tail(colors, 89)
  colors_train &lt;- head(colors, 810)
  
  colors_train_agg &lt;- aggregate(colors_train$Impressions, list(colors_train$`Position of Ad in Break`), FUN=mean, na.rm=TRUE)
  colnames(colors_train_agg) &lt;- c("ad_position", "avg_impressions")
  lm_colors &lt;- lm(colors_train_agg$avg_impressions ~ poly(colors_train_agg$ad_position, 12))
   summary(lm_colors)
  
  colors_test_agg &lt;- aggregate(colors_test$Impressions, list(colors_test$`Position of Ad in Break`), FUN=mean, na.rm=TRUE)
  colnames(colors_test_agg) &lt;- c("ad_position", "avg_impressions")
  new.df &lt;- data.frame(colors_test_agg$ad_position)
  colnames(new.df) &lt;- c("ad_position")
  colors_test_test &lt;- predict(lm_colors, newdata=new.df)
  </code></pre>
  
  <p>So I have exactly the same column names for both training and test data. I still get the warning: </p>
  
  <p><code>Warning message:
  'newdata' had 15 rows but variables found have 22 rows</code></p>
  
  <p>Can some one suggest what is wrong? Also, I want to know if I am even doing it the right way.</p>
  
  <p>Also, some pointers on how to calculate accuracy of the model will be greatly appreciated. Thanks!</p>