Hi,
Using the same datasets: dat1<- read.table(text=" V1 V2 V3 2 6 8 4 3 4 1 9 8 ",sep="",header=TRUE) dat2<- read.table(text=" V1 V2 V3 6 8 4 2 0 7 8 1 3 ",sep="",header=TRUE) sapply(seq_len(ncol(dat1)),function(i) cor(dat1[,i],dat2[,i],method="spearman")) #[1] -1.0000000 0.5000000 -0.8660254 #or diag(cor(dat1,dat2,method="spearman")) # V1 V2 V3 #-1.0000000 0.5000000 -0.8660254 A.K. ----- Original Message ----- From: laro <l_roh...@gmx.ch> To: r-help@r-project.org Cc: Sent: Friday, August 30, 2013 12:52 PM Subject: Re: [R] calculate with different columns from different datasets Thank you a lot A.K.! One more question: I'd like to compute the Spearman's rank correlation coefficients for V1 (from dat1) and V1 (from dat2) and so on... Do you know how to do that? I managed to write the Pearson's correlation product moment coefficient with your sapply-approach, but I have no idea how to rank it. Kind regards -- View this message in context: http://r.789695.n4.nabble.com/calculate-with-different-columns-from-different-datasets-tp4674918p4675034.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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. ______________________________________________ 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.