Skip to content
Back to formatted view

Raw Message

Message-ID: <825D3A85-D7A3-47EB-92C0-8A84745C8583@gmail.com>
Date: 2009-11-06T18:07:15Z
From: Nikhil Kaza
Subject: another question: how to delete one of columes in two ones with high correlation(0.95)
In-Reply-To: <26228174.post@talk.nabble.com>

You need  dim(cor.matrix)[1]

Following might be better instead of a loop, to to get the row ids of  
a matrix

(which(cor.matrix >=0.95) %/% dim(cor.matrix)[1])+1

for column ids use modulus instead of integer divison.

(which(cor.matrix >=0.95) %% dim(cor.matrix)[1])

There are probably better ways than this.

Nikhil

but probably a better way to do this would be

On 6 Nov 2009, at 3:16AM, bbslover wrote:

> for(i in 1:(cor.matrix[1]-1))
> {
>  for(j in (i+1):(cor.matrix[2]))
>   {
>      if (cor.matrix[i,j]>=0.95)
>      {
>          data.f<-data.f[,-i];
>           i<-i+1
>      }
>   }
> }