[R] remove rows of a matrix by part of its row name
ru|pb@rr@d@@ @end|ng |rom @@po@pt
Tue May 22 13:34:02 CEST 2018
Use grep to get the row indices and then subset with a *negative* index
to remove those rows.
rn <- scan(what = character(), text = "
mat <- matrix(rnorm(6*6), nrow = 6)
row.names(mat) <- rn
inx <- grep("73\\.", row.names(mat))
new_mat <- mat[-inx, ]
Hope this helps,
On 5/22/2018 11:48 AM, Ahmed Serag wrote:
> Dear R-experts,
> How can I remove a certain feature or observation by a part of its name. To be clear, I have a matrix with 766 observations as a rows. The row names are like this
> Now I would like to remove all the rows that contain the text 73.1
> Any ideas or suggestion please ?
> Ahmed Serag
> Analytical Chemistry Department
> Faculty of Pharmacy
> Al-Azhar University
> [[alternative HTML version deleted]]
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help