Reputation: 1
I have a big matrix (i.e 303*32). I want to create take out some columns and make a new matrix in R. I am unable to find any solution. Any help would be appreciated.
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.
By using this code i am only getting cols and rows name .
Upvotes: 0
Views: 254
Reputation: 33782
If you want to exclude columns by name, you need something like:
new_mat <- ads[, !colnames(ads) %in% c("speed","gaps","time")]
Upvotes: 2