I am new data science and I am learning data science using R. I have used the CART train function to train my model but I am getting the error.
The code is as follows:
control <- trainControl(method="cv", number=10)
lassogrid <- expand.grid(
alpha=1, lambda=seq(0.001, 0.1, by=0.0005)
)
lasso_model <- train(x=train0[,-c(which(names(train0)=="SalePrice"))],
y=train0$SalePrice, method = "glmnet", trControl="control",
tuneGrid="lassogrid")
I am getting error as below:
Error: $ operator is invalid for atomic vector
I researched it and found it is not because of the train(). I have no idea about the atomic vector. Can anyone tell me what is the error and how to solve it?