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
Hi Krys,
Please also cc all you responses to the list, keeping the conversation
in the archives. The following code might be of help to you:
set.seed(1)
bla = matrix(runif(1), 10, 10)
colnames(bla) = LETTERS[1:ncol(bla)]
cor_bla = cor(bla, method = "spearman")
# Assign NA to all values bel
Hi,
I'm not sure I understand what you want. This would have been easier if
you had provided a reproducible example. See the following code:
bla = matrix(runif(1), 10, 10)
cor_bla = cor(bla, method = "spearman")
Now what do you want to select. All the variables that have a
correlation hi
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
4 matches
Mail list logo