Matrix class not being recognized I have a data frame, and I am only interested in the numerical variables (variable class is double):
Example
A    B    C    D    E
0.13 2.22 3.44 3.30 6.54
3.55 4.23 0.43 5.33 3.55
...

I want to build a linear regression xgboost model, so I converted the data frame to a dense matrix.
I took out all categorical variables from my data, and am left with the five variables of interest. But I can't seem to be able to use the dense matrix, despite it being a type of input that xgboost accepts. See here. I am instead getting this error:
Error
&quot;Error in xgb.DMatrix(train_mat[, -n], label = train_mat[, n]) : [23:57:13] amalgamation/../dmlc-core/src/io/local_filesys.cc:66: LocalFileSystem.GetPathInfo 2007 Error:No such file or directory&quot;.
Code
train_mat &lt;- as.matrix(subset(train, select = -c(Genre, Publisher, Rank, Name, Platform)))

lm.boosted &lt;- xgb.train(data = train_mat, booster= &quot;gblinear&quot;, max_depth=3, nthread=1, nrounds = 2, eval_metric=&quot;error&quot;, eval_metric= &quot;rmse&quot;, objective= &quot;reg:linear&quot;)

I tried to convert to a xgb.DMatrix, but I am not clear on what it's asking for to do the conversion.
train_mat &lt;- xgb.DMatrix(data = train_mat, label= train$Global_Sales)

How do I input data into xgboost?
Following this example:

Suppose the last column in train_mat is the label that needs to be predicted, i.e. Global_Sales, then you construct the xgb.DMatrix as:

n &lt;- ncol(train_mat)    # or if not the last, the position of the label column
dtrain &lt;- xgb.DMatrix(train_mat[,-n], label=train_mat[,n])


To train the model, simply pass dtrain to the data parameter:

lm.boosted &lt;- xgb.train(data = dtrain, booster= "gblinear", max_depth=3, nthread=1, nrounds = 2, eval_metric="error", eval_metric= "rmse", objective= "reg:linear")