R/corOfQuantiles.R

Defines functions corOfQuantiles

Documented in corOfQuantiles

#' Compute correlation coefficients for quantiles
#' 
#' Computes correlation coefficients of the quantiles. 
#' 
#' This is a way to quantify the similarity between statistical distributions.
#' 
#' @param df A data frame
#' @param method Defults to "pearson". Can also be "kendall", "spearman".
#' @export



corOfQuantiles <- function(df, method = "pearson") {
  for( i in 1:ncol(df)){
    df[,i] <- df[,i][order(df[,i])]  # orders observations to get the quantiles
  }
  return(cor(df, method = method))
}
msxakk89/dat documentation built on Aug. 3, 2020, 6:39 p.m.