删除第1列到第5列
data <- data[,-(1:5)]
也可使用dplyr包中函数进行操作
library(dplyr)
按索引删除
data <- select(data,-3)
删除多列,指定列号即可
data <- select(data,-1,-2,-3,-4,-5)
按列名删除单列
data <- select(data,-lieming)
按列名删除多列
data <- select(data,-c(lieming1,lieming2))
data <- data[,-(1:5)]
library(dplyr)
data <- select(data,-3)
data <- select(data,-1,-2,-3,-4,-5)
data <- select(data,-lieming)
data <- select(data,-c(lieming1,lieming2))
本文标题:R语言删除矩阵指定列
本文链接:https://www.haomeiwen.com/subject/hiunkrtx.html
网友评论