简体   繁体   中英

'data' must be a data.frame, not a matrix or an array error in R

I already loaded the data set and now Im getting this:

defaults <- ifelse(defaults == "no", 0, 1)
set.seed(123)
train_idx <- sample(nrow(defaults), .70*nrow(defaults))
defaults_train <- defaults[train_idx,]
defaults_test <- defaults[-train_idx,]
mod1 <- glm(Y ~ LIMIT_BAL + BILL_AMT1 + PAY_AMT6, family = binomial, data=defaults_train)

Error in model.frame.default(formula = Y ~ LIMIT_BAL + BILL_AMT1 + PAY_AMT6, : 'data' must be a data.frame, not a matrix or an array

Any idea how to fix this to not get the error?

check the class of defaults (class(defaults)),train_idx and defaults_train. Is your loaded dataset named defaults?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM