title: why the predict() function does have different rows in R
body: <p>I am trying to predict data with linear regression. There is no error but it is kind of weird. I created a linear regression from data1 which has 4000 rows, but i am trying to predict data2 with this linear regression which has only 1000 rows.</p>
  <p>Then, i think the result of variable should be just 1000 rows. But it keeps showing the 4000 variables. I do not know what is wrong.</p>
  <pre><code>model = lm(train$crashes ~ train$latitude)
  prediction1 = predict(model, newdata = test)
  csv1 = data.frame(Id = c(1:1000), Predicted = prediction1)
  </code></pre>
  <p>From this code, I believe it just needs to predict &quot;test&quot; data which has only 1000 rows. But it says that &quot;arguments imply differing number of rows: 1000, 4337&quot; Here the 4337 is from the train data which has 4337 rows.</p>
  <p>I think i am doing wrong. How to fix it?</p>