I have a data.frame that includes factor and numeric variables, as may be seen below.
testFrame = data.frame(First=sample (1:10), Second=sample (1:20), Third=sample (1:10), Replace=T);
Fifth=rep(c("Edward","Frank","Georgia","Hank","Isaac"),4) I want to construct a matrix that assigns dummy variables to the factor and leaves the numeric variables alone. Fourth=rep(c("Alice","Bob","Charlie","David"), 5), and Fifth=rep(c("Edward","Frank","Georgia
First + Second + Third + Fourth + Fifth, data=testFrame, model.matrix
This eliminates the reference level for one level of each factor, as expected when executing lm. But I want to create a matrix that includes a dummy or indicator variable for each level of every factor. I am not concerned about multicollinearity because I am developing this matrix for glmnet.
Is there a way to have model.matrix create the dummy for every level of the factor?