[R] Correlation
Rui Barradas
ruipbarradas at sapo.pt
Sun Jul 27 14:00:42 CEST 2014
Hello,
If I understand it correctly the following should do it. Note that it
removes both columns and rows.
idx <- corData > 0.5
diag(idx) <- FALSE
idx2 <- which(apply(idx, 2, function(x) !any(x)))
corData[-idx2, -idx2]
Use corData[, -idx2] to remove only columns.
Hope this helps,
Rui Barradas
On 27/07/2014 12:40, Nico Met wrote:
> Dear all,
>
> I have written the following code for correlation calculations. I want to
> create a new matrix from corData) with correlation more than 0.5 only and
> the rest of the columns should be removed. How can I do it?
>
>
> set.seed(1234)
> data<-matrix(rnorm(100),nrow=10)
> data[,1]<-100*(data[,2]+data[,5]+data[,9])
> corData<-cor(data)
>
> Thanks a lot
>
> Nico
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list