I am sorry to repeat this question over and over but it seems that I have poor understanding in predicting wider range. It seems that if the data's nrow matches well with predicting values you have no error. However, if you want to predict for different range we will be getting an error.
Using the same data from dplyrdo-requires-named-function
it works well. But if you want to change the range of the fitting I am getting an error!
library(dplyr)
iris %>%
group_by(Species) %>%
do({
mod <- lm(Sepal.Length ~ Sepal.Width, data = .)
pred <- predict(mod, newdata = data.frame(Sepal.Width=seq(1,10,length.out=51)))
data.frame(., pred)
})
Error in data.frame(., pred) : arguments imply differing number of rows: 50, 51
I understand that the new range does not match with the previous data .
.
OTH, I need to predict for wider range of Sepal.Width
values. Is this possible ?