You can set it to NULL
.
(您可以将其设置为NULL
。)
> Data$genome <- NULL
> head(Data)
chr region
1 chr1 CDS
2 chr1 exon
3 chr1 CDS
4 chr1 exon
5 chr1 CDS
6 chr1 exon
As pointed out in the comments, here are some other possibilities:
(正如评论中指出的那样,这里还有其他一些可能性:)
Data[2] <- NULL # Wojciech Sobala
Data[[2]] <- NULL # same as above
Data <- Data[,-2] # Ian Fellows
Data <- Data[-2] # same as above
You can remove multiple columns via:
(您可以通过以下方式删除多列:)
Data[1:2] <- list(NULL) # Marek
Data[1:2] <- NULL # does not work!
Be careful with matrix-subsetting though, as you can end up with a vector:
(但是,请谨慎使用矩阵子集,因为您可能会得到一个向量:)
Data <- Data[,-(2:3)] # vector
Data <- Data[,-(2:3),drop=FALSE] # still a data.frame
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…