[R] search through a matrix

onyourmark william108 at gmail.com
Tue Apr 21 14:33:25 CEST 2009


Thanks very much.

I don't really understand the row() function. I looked in the reference but
I don't really get it. It says:
Description
Returns a matrix of integers indicating their row number in a matrix-like
object, or a factor indicating the row labels. 

Usage
row(x, as.factor = FALSE)

Arguments
x a matrix-like object, that is one with a two-dimensional dim. 

I don't understand what row() does. 

And in the example in the documentation it says:
x <- matrix(1:12, 3, 4)
# extract the diagonal of a matrix
dx <- x[row(x) == col(x)]
dx
[1] 1 5 9

I thought the single square bracket notation accepts a pair separated by a
comma but I don't see how 
row(x)==col(x) produces that?

Thanks again.


onyourmark wrote:
> 
> Hi. I have a 925 by 925 correlation matrix corM. I want to identify all
> variables that have correlation greater than 0.9.  Can anyone suggest an
> "R way" of doing this?
> 
> Thank you.
> 

-- 
View this message in context: http://www.nabble.com/search-through-a-matrix-tp23153538p23155104.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list