I used caret package for cross validation but when I tried to use the prediction i got an error indicating : " replacement has 1118691 rows, data has 1118705"
. When I used the regular lm() it does the prediction just fine.What can be a solution for this error?
I can't deliver my data set this time but when I tested my code on a toy data frame the prediction works.So I guess it is somthing that is related to the data itself.
Here are my lines of code (works fine on the toy data):
df <- read.table(text = "dateTime birds wolfs snakes
2014-05-21 9 7 a
2014-04-28 8 4 b
2014-04-13 2 8 c
2014-03-12 2 3 a
2014-02-04 8 3 a
2014-02-29 1 2 a
2014-01-17 7 1 b
2014-01-16 1 5 c
2014-09-20 9 7 c
2014-08-21 8 7 c ",header = TRUE)
fitControl3 <- trainControl(## 10-fold CV
method = "repeatedcv",
number = 3,
## repeated 3 times
repeats = 3)
df$lm_pred<-predict(df_model,newdata=df,type='raw')