[BioC] conditional selection: extracting row from matrix
w.huber at dkfz-heidelberg.de
w.huber at dkfz-heidelberg.de
Tue Jan 6 19:03:16 MET 2004
Hi,
> matrix[,matrix[,2]==513.193057]
> (Error: (subscript) logical subscript too long)
matrix[,2]==513.193057 returns a logical vector the length of which is the
number of rows of 'matrix'. Thus you would want to write
matrix[matrix[,2]==513.193057, ]
> index <- which(matrix[,2] == 513.193057)
> matrix[index,]
Note that all of the above may be problematic because of round-off errors,
most likely this expression will not match for any row of 'matrix'. Please
read the help pages on the == operator and the all.equal function (type:
> help("==")
> help(all.equal)
Maybe
matrix[abs(matrix[,2]-513.19 < 0.01), ]
would be the simplest solution.
Best wishes
Wolfgang
More information about the Bioconductor
mailing list