CreateDataPartition gave me an error: "data" must be of vector type, was "NULL"

I got below error while I was trying to use the CreateDataPartition () function from the caret package. Here the y variable takes a vector and I am passing a column from my data.frame. Hope it's in the correct format. I still don't understand why this is giving me an error.

My code:

bikeInTrain<-createDataPartition(y=bikeTrainRaw$datetime, p=0.7,list = FALSE)

Mistake:

Error in matrix(unlist(out), ncol = times) : 'data' must be of a vector type, was 'NULL'

the datetime column has a factor class. Should I change this to something else? Let me know If I'm wrong somewhere.

+3


source to share





All Articles