obtaining row indexes from a list of column indexes
Thanks -- I want to retrieve the one list of indexes from the other, without constructing the matrix. m and n might be 1e6, so constructing the full matrix is to be avoided.
On 11/17/2010 08:55 PM, caspar hallmann wrote:
Edzer, say m is your matrix of TRUE's and FALSE's, then: which(m,arr.ind=TRUE) will give you the column and row numbers of the matrix satisfying the conditions supplied to which. Hope it helps Caspar On Wed, Nov 17, 2010 at 8:29 PM, Edzer Pebesma <edzer.pebesma at uni-muenster.de> wrote:
List,
given an arbitrary n x m boolean matrix, say
[,1] [,2] [,3] [,4] [,5]
[1,] FALSE FALSE FALSE FALSE FALSE
[2,] FALSE FALSE TRUE FALSE FALSE
[3,] FALSE FALSE FALSE FALSE FALSE
[4,] FALSE FALSE FALSE TRUE TRUE
I have the TRUE entries (indexes) of each column, in a list
[[1]]
integer(0)
[[2]]
integer(0)
[[3]]
[1] 2
[[4]]
[1] 4
[[5]]
[1] 4
How can I, from this list, efficiently obtain the TRUE entries of each
row, in this case
[[1]]
integer(0)
[[2]]
[1] 3
[[3]]
integer(0)
[[4]]
[1] 4 5
without constructing the n x m boolean matrix?
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of M?nster
Weseler Stra?e 253, 48151 M?nster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics e.pebesma at wwu.de
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Edzer Pebesma Institute for Geoinformatics (ifgi), University of M?nster Weseler Stra?e 253, 48151 M?nster, Germany. Phone: +49 251 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de http://www.52north.org/geostatistics e.pebesma at wwu.de