# a variance matrix
V <- diag(rep(0.5, 5)) + 0.5
D <- chol(V)
# simulate two correlated matrices
x <- matrix(rnorm(100), ncol=5)y <- matrix(rnorm(100), ncol=5)
# create shuffled version of the second matrix
u <- sample(1:ncol(y))
z <- y[,u]
# correlations with paired columns
corbetw2mat(x, y)
# the same with y columns shuffled
corbetw2mat(x, z)
# for each column x, find column of y with max correlation
corbetw2mat(x, y, what="bestright")
# the same with y columns shuffled
corbetw2mat(x, z, what="bestright")
# all pairs of columns with correlation >= 0.6
corbetw2mat(x, y, what="bestpairs", corthresh=0.6)
# the same with y columns shuffled
corbetw2mat(x, z, what="bestpairs", corthresh=0.6)
# all correlations
corbetw2mat(x, y, what="all")
Run the code above in your browser using DataLab