我有一个大矩阵(即303 * 32)。我想创建取出一些列并在R中创建一个新矩阵。我无法找到任何解决方案。任何帮助将不胜感激。
ads # Matrix of 303*32
new_mat <- matrix(c("speed","gaps","time")) # speed, gaps and times are names of cols which I am trying to exclude.
通过使用此代码,我只获取cols和rows name。
答案 0 :(得分:2)
如果您想按名称排除列,则需要以下内容:
new_mat <- ads[, !colnames(ads) %in% c("speed","gaps","time")]