I'm using linear regression to attempt and forecast certain data. Even though there is no fault, it is strange. In order to forecast data2, which only has 1000 rows, I used a linear regression that I generated from data1, which has 4000 rows.

So, in my opinion, the variable's output should only contain 1000 rows. However, the 4000 variables never stop appearing. I have no idea what's wrong.

model = lm(train$latitude train$crashes)

Model, newdata = test, prediction1 = predict

data.frame = csv1

(Id = c(1:1000), Predicted = prediction1)

From this code, I believe it just needs to predict "test" data which has only 1000 rows. But it says that "arguments imply differing number of rows: 1000, 4337" Here the 4337 is from the train data which has 4337 rows.