Skip to content
Prev 374717 / 398506 Next

remove rows of a matrix by part of its row name

Hello,

Use grep to get the row indices and then subset with a *negative* index 
to remove those rows.

rn <- scan(what = character(), text = "
70/556
71.1/280
72.1/556
72.1/343
73.1/390
73.1/556
")

mat <- matrix(rnorm(6*6), nrow = 6)
row.names(mat) <- rn

inx <- grep("73\\.", row.names(mat))

new_mat <- mat[-inx, ]
new_mat


Hope this helps,

Rui Barradas
On 5/22/2018 11:48 AM, Ahmed Serag wrote: