Florence Combes wrote:

> Hi 
> 
> I want to do something which seems straightforward, but I couldn't find the 
> way to do this. 
> I have a matrix called m for example, and a vector of values (let's call ind 
> this vector) which are indices of lines I don't want to keep. 
> 
> for example I have:
> 
> 
>>m
> 
> v1 v2 v3
> [1,] 1 4 7
> [2,] 2 5 8
> [3,] 3 6 9
> [4,] 10 11 12
> 
> 
>>ind
> 
> [1] 2 4
> 
> 
> I would like to obtain this:
> 
> 
>>m2
> 
> v1 v2 v3
> [1,] 1 4 7
> [3,] 3 6 9
> 
> by saying something like 
> 
> m2<-m[!=(ind),] 



See help("[") and learn about negative indices:

m2 <- m[-ind,]

Uwe Ligges


> but this line does not work. 
> 
> Any idea or suggestion highly welcome !
> 
> Florence.
> 
>       [[alternative HTML version deleted]]
> 
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to