splitting data for prediction

Odataset2 <- read.csv ("C:/Users/FBDA17-031/Documents/OlyDash/Odataset2.csv")
Odataset2 <- Odataset2%>%
 mutate(model = ifelse(Date <= "Date", "train", "test"))

colnames(Odataset2)<- colnames(Date)
Odataset2 <- xts(Odataset2, as.Date(as.character(Odataset2$Date.To.Date), format="%m/%d/%Y"))

I keep getting the error below when running the code above,.. and can't seem to fix it

Error in xts(Odataset2, as.Date(as.character(Odataset2$Date.To.Date), : NROW(x) must match length(order.by)

what could be the problem?


In order for us to help you with your question, please provide us a minimal reproducible example where you provide a minimal (dummy) dataset and code that can recreate the issue. Once we have that, we can go from there. For help on creating a Reprex, see this guide:

Good luck!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.