I am trying to create a model using glmnet, (currently using cv to find the lambda value) and I am getting an error NA/NaN/Inf in foreign function call (arg 5)
.
Chars datatypes that are converted to factors cannot be supported for cv.glmnet, as stated above, can't handle NA's. Either use as.numeric or as.double.
Addition: In case that you get this error without having NA's in your dataframe, you probably haven't defined your input matrix with the model.matrix function.
x <- model.matrix( ~ ., Data)
I know it is not the answer to your question but i had the same error as you and found this solution. So it might be helpful for others.
It appears that glmnet cannot handle NA values!