knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

This document introduces you to the two main functions of the package:

Compute correlation coefficients and Cramér's V

To explore the basics of the package, we'll use the mtcars dataset and the tea dataset.

The mtcars dataset is built-in in R and the tea dataset comes originally from the FactoMineR package but it's also shipped with corr.


Computing a correlation coefficient or the Cramér's V is simple:

library("corr")

results <- compute_cor(tea, method = "cramer")

Four methods are available:

The "pearson", "kendall" or "spearman" methods should be used for numerical variables. See stats::cor() for more details.

On the other hand, the "cramer" method is usefull to measure the association between nominal variables (see the wikipedia article for more).

Visualize the results

After computing the correlation, you can use the plot_cor() function to visualize the results with a heatmap.

results <- compute_cor(mtcars, method = "pearson")
plot_cor(results)


Different options are available (see help(plot_corr) for the whole list).

For instance, we can plot only the lower triangle of the matrix, change the palette of colors and reorder the variables by an "optimal" number of groups.

plot_cor(results, type = "lower", palette = "inferno", clustering = TRUE)


thoera/corr documentation built on May 8, 2019, 11:59 p.m.