> xfactors<-model.matrix(Class ~ CUST_REGION_DESCR + cust_prog_level,data=down_train)[,-1]
> x = as.matrix(data.frame(down_train$Sales,xfactors))
> glmmod = glmnet(x,y=as.factor(Class),alpha=1,family='binomial')
Error in is.factor(x) : object 'Class' not found

Somehow, "Class", which is my binomial variable, disappears.
I am trying to build a logistic regression model. The glmnet() package requires me to input a matrix which explain why I called as.matrix() function.
I follow a post on Stack Overflow.
The author of the post said there was not error when he or she ran glmnet() but I am having issue wit that.

How can I approach this error? It is obvious that object "Class" not found since when I called head(x), I have:

I’ll add that the call to data.frameshould have failed for a different reason — that neither of those first 2 objects could be found. That it didn’t implies that you have either created separate variables with those names at some point (confusing and therefore dangerous!) or attach()ed your down_train data frame at some point (also confusing and therefore dangerous!). Might be a good time to restart your R session (assuming you know how to recreate any important objects — and if not, that’s another important problem to solve!).

R doesn't know where to find Class, since it's a variable in a data frame, but you haven't told glmnet that. To refer to Class in this context, you need to specify it as down_train$Class.

This is admittedly a confusing area because some functions in R (and in R packages) allow shortcuts via what's called Non-Standard Evaluation, so that you don't always have to fully specify variables from a data frame. One case you've already seen: when a function takes a formula and a data parameter, then the variables in the formula do not have to be fully specified. But that's a special situation, not the default.

@jcblum
I am sorry I don't know your name so I will call you jcblumn for now.
Additional help: where to find a good laid-back explanation of glmnet() package?
For instance, I want to understand what the message glmnet() delivers?
Maybe a source with an example, result, interpretation?

I think "cv" stands for "cross validation". What does it do in the Logistic Regression Model?

I know the lm() package builds a linear regression model. Does glmnet() also build a regression model that helps to predict whether the predict "Class" responds to the Independent Variables on the right hand side?