[R] remove elements from matrix
bt_jannis at yahoo.de
Fri Sep 30 12:23:36 CEST 2011
Try this. As you did not supply a reproducible example my code is untested:
1.m.vector[index.vector] <- NULL
new.1.m.vector <- 1.m.vector[- index.vector]
Someting equivalent is possible for the matrix.
On 09/30/2011 11:30 AM, Alaios wrote:
> Dear all,
> I have a numeric vector that contains indices.
> I also have two matrices of [1,m] dimension and of [m,n] dimension.
> I want for every indexto remove the current element from the [1,m] vector an the row from the [m,n] matrix.
> How I can do that efficiently in R? So to say not have a for loop getting parameter after parameter and then removing row by row from the vector and the matrix.
> I would like to thank you in advance
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> 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