I've encountered this knit issue with R studio.
I have a dataset with dimension (543, 31) and I split it into train and test with:
set.seed(1)
train=sample(c(TRUE ,FALSE), nrow(dataset),rep=TRUE)
test=(!train)
y.test=y[test]
And then I applied ridge regression on the training set and predict on the test set with:
ridge.mod.train=glmnet(x[train,],y[train],alpha=0, lambda =grid,thresh=1e-12)
ridge.pred=predict(ridge.mod.train,s=3, newx=x[test,])
I can run it in my console window in R studio, but every time I try to knit to PDF, I got this error below. I tried restart R studio and clear workspace, bu none seems to work.
Error in x[train, ] : incorrect number of dimensions
Calls: <Anonymous> ... as.formula -> formula -> formula.default -> eval
-> eval
Execution halted .