cor_matrix function

Correlation Matrix

Correlation Matrix

This function produces the matrix of correlations between all quantitative variables in a dataframe.

cor_matrix(X,type="pearson")

Arguments

  • X: A data frame
  • type: Either pearson or spearman. If pearson, the Pearson correlations are returned. If spearman, the Spearman's rank correlations are returned.

Details

This function filters out any non-numerical variables and provides correlations only between quantitative variables. Best for datasets with only a few variables. The correlation matrix is returned (with class matrix).

References

Introduction to Regression and Modeling

Author(s)

Adam Petrie

See Also

cor

Examples

data(TIPS) cor_matrix(TIPS) data(AUTO) cor_matrix(AUTO,type="spearman")
  • Maintainer: Adam Petrie
  • License: GPL (>= 2)
  • Last published: 2020-02-21

Useful links