I changed the condition to: highlyCor<-cbind(rownames(x)[row(x)[((x > 0.9)|(x<(-.9)))]], colnames(x)[col(x)[((x > 0.9)|(x<(-.9)))]])
Actually what I am trying to do is run factor analysis on this 923 by 925 x matrix but many of the variables where too highly correlated and so I got some message about singular and that the factanal could not run. Is there a way to choose to remove one variable from each pair of highly correlated variables (say variables with greater than .9 or less than -.9 correlation) and receive a new smaller x matrix which I can then do factor analysis on? Thanks. Uwe Ligges-3 wrote: > > > > 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. > > Example: > > # prepare example data: > x <- matrix((1:25) / 25, 5, 5) > rownames(x) <- letters[1:5] > colnames(x) <- letters[1:5] > > # solution > cbind(rownames(x)[row(x)[x > 0.9]], colnames(x)[col(x)[x > 0.9]]) > > > Uwe Ligges > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://www.nabble.com/search-through-a-matrix-tp23153538p23169908.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.