[R] matrix indexing

From: toka tokas <tokkass_at_yahoo.com>
Date: Thu 18 Aug 2005 - 19:02:13 EST

Dear R-users,

I was wondering for the following:

Let 'x' be a matrix and 'ind' and indicator matrix, i.e.,

x <- array(1:20, dim = c(4, 5))
ind <- array(c(1:3, 3:1), dim = c(3, 2))

I'd like to get (as a vector) the elements of 'x' which are not indexed by 'ind'. Since negative indices are not allowed in index matrices I thought of using something like:

x[ind] <- NA

but are there any more elegant solutions.

Thanks in advance,

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Aug 18 19:07:00 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:51 EST