why the predict function does have different rows in R

0 votes
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.
Jun 23 in Data Analytics by avinash
• 860 points
18 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Data Analytics

0 votes
1 answer

why the predict() function does have different rows in R

Alter this sentence: model = lm(train$latitude train$crashes) to lm(crashes ...READ MORE

answered 6 days ago in Data Analytics by Sohail
• 2,960 points
5 views
0 votes
1 answer

What does the sink function do in R?

sink diverts R output to a connection ...READ MORE

answered May 24, 2019 in Data Analytics by Chandu
487 views
0 votes
2 answers

R function for finding the index of an element in a vector?

The function match works on vectors : x <- sample(1:10) x # ...READ MORE

answered Dec 12, 2020 in Data Analytics by Rajiv
• 8,910 points
51,669 views
+1 vote
2 answers

Which function can I use to clear the console in R and RStudio ?

Description                   Windows & Linux           Mac Clear console                      Ctrl+L ...READ MORE

answered Apr 17, 2018 in Data Analytics by anonymous
46,973 views
0 votes
1 answer

Why should I use set.seed function() in R?

set.seed(seed) Set the seed of R‘s random number ...READ MORE

answered Apr 24, 2018 in Data Analytics by zombie
• 3,790 points
800 views
0 votes
1 answer

How to write a custom function which will replace all the missing values in a vector with the mean of values in R?

Consider this vector: a<-c(1,2,3,NA,4,5,NA,NA) Write the function to impute ...READ MORE

answered Jul 4, 2018 in Data Analytics by CodingByHeart77
• 3,720 points
3,159 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
422 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
467 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
4,287 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
492 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP