If I understand correctly, you can use which( ,arr.ind=TRUE):

Assuming that you start with a data frame,

 dat <- as.data.frame(matrix(runif(30), ncol=5))
 nm <- names(dat)
 cormat <- cor(dat)
 cormat[lower.tri(cormat, diag=TRUE)] <- NA
 idx <- which(cormat > 0.4, arr.ind=TRUE)
 idx
 cbind(nm[idx[, "row"]], nm[idx[, "col"]])

will give you the pairs.

 -Peter Ehlers

Krystyna Golabek wrote:
Dear R users,

Simple question. Can anyone help with the code that would allow me to view only the variables who's correlation output is >0.8?
This is the code I'm using to date
cor(data, method="spearman")

Kind regards
Krys


--------------------------------------------





_________________________________________________________________
Save time by using Hotmail to access your other email accounts.

        [[alternative HTML version deleted]]

______________________________________________
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.



______________________________________________
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.

Reply via email to