R/dcor_list.R

#' 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)
}
jasonzyx/aSPC documentation built on May 18, 2019, 5:55 p.m.