r- caret package error- createDataParition no observation -


i'm getting following error when try run createdatapartition in caret.

error in createdatapartition(data1, p = 0.8, list = false) :    y must have @ least 2 data points 

i ran same exact same code last night no errors. thoughts?

predictors<- with(df, data.frame(xvar, xvar, xvar, xvar)) data1<-with(dfu2, data.frame(data1)) library(caret) set.seed(1) trainingrows<- createdatapartition(data1,                                    p=.80,                                    list=false) > dput(head(data1, 15)) structure(list(data1 = c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 0l, 0l, 1l, 0l, 0l, 0l, 1l, 1l)), .names = "data1", row.names = c(na, 15l), class = "data.frame") 

the data frame data1 visible in environment , has expected observations. thought?

this not work because data1 data.frame in case whereas should vector mentioned documentation of ?createdatapartition. see example:

#using data data1 <- structure(list(data1 = c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 0l, 0l, 1l, 0l, 0l, 0l, 1l, 1l)), .names = "data1", row.names = c(na, 15l), class = "data.frame") 

now if do:

> createdatapartition(data1) error in createdatapartition(data1) : y must have @ least 2 data points 

i same error you. whereas, if vector:

> createdatapartition(data1[[1]] ) $resample1 [1]  1  2  3  4  8  9 12 15 

it works great.

so use data1[[1]] in code in createdatapartition call , work.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -