Skip to content

selecting for values above or within a range in the data matrix

2 messages · akchong at bidmc.harvard.edu, Peter Ehlers

#
Hi All,
I am new to the R program (only my 2nd day trying it out!) and this may seem like a really stupid question but I was wondering if someone could help. I have managed to calculate the pearson correlation coefficient for my data and now I have a correlation coefficient matrix with a whole slew of numbers. I was wondering if there is a way to only show the correlation coefficient values that are between +0.85 to +1.0 and/or -0.85 to -1.0 in the matrix table.

Thanks in advance,
Allen
#
On 2010-12-08 12:03, akchong at bidmc.harvard.edu wrote:
Maybe something like this:

  set.seed(1066)
  m <- matrix(sample(10, 20, TRUE), 5, 4)
  cm <- cor(m)
  ind <- which(abs(cm) < 0.85)
  is.na(cm) <- ind
  round(cm, 2)

Peter Ehlers