[R] another question: how to delete one of columes in two ones with high correlation(0.95)
bbslover
dluthm at yeah.net
Sat Nov 7 07:42:42 CET 2009
thank you. I need learn it, after that, maybe I can understant it well.
thank Nikhil
Nikhil Kaza-2 wrote:
>
> 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
>> }
>> }
>> }
>
> ______________________________________________
> R-help at 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://old.nabble.com/another-question%3A-how-to-delete-one-of-columes-in-two-ones-with-high-correlation%280.95%29-tp26228174p26240884.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list