I want to run a regression model using creatFolds function and specific set.seed.
I can run the regression model without creatFolds function with no Error.
The friedman dataset can be found here
wdbc <- read_csv("friedman.dat", col_names = FALSE, skip = 10)
wdbc[] <- lapply(wdbc, scale)
The regression model without createFolds Function
lm(X6 ~ ., data = wdbc)
Call:
lm(formula = X6 ~ ., data = wdbc)
Coefficients:
(Intercept) X1 X2 X3 X4 X5
2.553e-16 3.892e-01 3.563e-01 2.834e-04 5.739e-01 2.767e-01
The regression model with createFolds Function
FX <- function(seed, data, k=30) {
set.seed(seed)
folds <- createFolds(data[, "X6"], k=k, list=TRUE, returnTrain=TRUE)
lm1 <- lapply(folds, function(folds) lm(X6 ~ ., data=data[folds, ]))
}
seeds <- 1:30
res <- lapply(seeds, FX, data=wdbc)
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
0 (non-NA) cases