Matrix class not being recognized
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")