#' calculate the correlation matrix by dcor() in package energy
#'
#' @param ls1, first list of distance matrices for p columns in df1
#' @param ls2, second list of distance matrices for p columns in df1
#' @return a p by q correlation matrix
#' @importFrom energy dcor
dcor_list <- function(ls1, ls2){
each_row <- function(y) {
sapply(1:length(ls2), function(x) dcor(ls2[[x]],ls1[[y]]))
}
cor_mat <- t(sapply(1:length(ls1), each_row))
return(cor_mat)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.