R/calculate_max_correlation.r

#' @keywords internal
#'
calculate_max_correlation <- function(data, columns) {
  
  x <- combn(columns, 2)
  
  mx <- 0
  for(i in 1:(x %>% ncol())) {
    
    y1 <- data[, x[1,i]] %>% as.numeric()
    y2 <- data[, x[2,i]] %>% as.numeric()
    mx <- max(mx, cor(y1, y2, use = "p") %>% abs())
  }
  
  mx
}
markanewman/mndredge documentation built on May 9, 2019, 5:52 a.m.