R/int_correlations.R

Defines functions intercorrelation

Documented in intercorrelation

#' Intracorrelation
#'
#' Calculates the intercorrelation between ids
#' (the correlation between different ids)
#' @param A Matrix
#' @param ids Vector of ids of the sample
#' @return the pearson coefficient
intercorrelation <- function(A, ids) {
  stopifnot(is.matrix(A))
  stopifnot(length(ids) != ncol(A))

  x <- cor(A)
  sameIDs <- outer(ids, ids, "==")
  unlist(x[upper.tri(x) & !sameIDs], use.names = FALSE)
}
llrs/integration-helper documentation built on Sept. 24, 2021, 10:57 a.m.