Error in model.frame.default(object, data, xlev = xlev) : object is not a matrix
<p>3 days old to R and can't figure out what I'm doing wrong.  I'm trying to send some columns with two way interactions into a glmnet cox model.  I have some data.frame() called dtable</p>

<p><em>Edit to make the code reproducible</em></p>

<pre><code>xs&lt;-c("Col1", "Col2", "Col3")
v&lt;-c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, NA, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, NA, 25, 26, 27, 28, 29, 30)
df&lt;-data.frame(matrix(v,ncol=3))
dm&lt;-as.matrix(df)
dm&lt;-matrix(dm[complete.cases(dm)], ncol=3)
colnames(dm)&lt;-xs
dfdata&lt;-data.frame(dm)
f&lt;-as.formula(time~.*.)
xmatrix&lt;-model.matrix(f, dfdata)[,-1]
</code></pre>

<p>When I run this I get the error</p>

<pre><code>Error in model.frame.default(object, data, xlev = xlev) :    
object is not a matrix
</code></pre>

<p>Thanks in advance</p>