R/cor2.R

Defines functions cor2

#' Overlay on stats cor function to handle constant vectors.
#'
#' When a vector is constant, we say its correlation with other vectors is 0.
#' @noRd
cor2 <- function(x, y = x) {
  suppressWarnings(cor_matrix <- cor(x, y, use = "pairwise.complete.obs"))
  cor_matrix[is.na(cor_matrix)] <- 0
  return(cor_matrix)
}

Try the RGCCA package in your browser

Any scripts or data that you put into this service are public.

RGCCA documentation built on Oct. 9, 2023, 5:09 p.m.