Hi! All, I am working on a correlation matrix of 4217x4217 named 'cor_expN'. I wish to obtain pairs with highest correlation values. So, I did this > b=matrix(data=NA,nrow=4217,ncol=1) > rownames(b)=rownames(cor_expN) > for(i in 1:4217){b[i,]=max(cor_expN[i,])} > head(b) [,1] aaeA_b3241_14 0.7181912 aaeB_b3240_15 0.7513084 aaeR_b3243_15 0.7681684 aaeX_b3242_12 0.5230587 aas_b2836_14 0.6615927 aat_b0885_14 0.6344144
Now I want the corresponding columns for the above values. For that I tried this > c=matrix(data=NA,nrow=4217,ncol=1) > for(i in 1:4217){b[i,]=colnames(max(cor_expN[i,]))} And got the following error: Error in b[i, ] = colnames(max(cor_expN[i, ])) : number of items to replace is not a multiple of replacement length Any thoughts? Lee [[alternative HTML version deleted]] ______________________________________________ R-help@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.