R 将数据更改为矩阵

R 将数据更改为矩阵,r,xgboost,R,Xgboost,我不理解这里的[,-1]索引部分dat指的是数据,这有什么作用 示例代码: data_variables <- as.matrix(dat[,-1]) 数据变量关于从矩阵索引值的一些参考注释: 如果x是您的数据文件 x[i, j] #pulls the specific value at row i, column j x[i, ] #pulls the values from row i x[ , j] #pulls the values fro

我不理解这里的
[,-1]
索引部分
dat
指的是数据,这有什么作用

示例代码:

data_variables <- as.matrix(dat[,-1])

数据变量关于从矩阵索引值的一些参考注释:
如果x是您的数据文件

x[i, j]       #pulls the specific value at row i, column j
x[i, ]        #pulls the values from row i
x[ , j]       #pulls the values from column j
x[ , c(1, 3)] #pulls values from specifically columns 1 and 3
x["name", ]   #pulls the values from the row titled "name"
x[-2, ]       #pulls values from all rows EXCEPT column 2
x[ , -(3:4)]  #pulls all column values EXCEPT columns 3 & 4

注意:使用减号仅适用于行号或列号。不能将减号与“名称”标识符一起使用。这将生成一个错误代码。

它不包括第一列请参见的第2.7节