all_correlations function

Pairwise correlations between quantitative variables

Pairwise correlations between quantitative variables

This function gives a list of all pairwise correlations between quantitative variables in a dataframe. Alternatively, it can provide all pairwise correlations with just a particular variable.

all_correlations(X,type="pearson",interest=NA,sorted="none")

Arguments

  • X: A data frame
  • type: Either pearson, spearman, or both. If pearson, the Pearson correlations are returned. If spearman, the Spearman's rank correlations are returned.
  • interest: If specified, returns only pairwise correlations with this variable. Argument should be in quotes and must give the exact name of the column of the variable of interest.
  • sorted: Either none, strength, significance, or magnitude. If strength, sorts the list from most negative correlation to most positive (remember, correlations are stronger the farther they are from 0 (positive or negative). If significance, sorts the list by p-value. If none, no sorting takes place. Note: if both is requested, no sorting takes place and an error message is output.

Details

This function filters out any non-numerical variables in the data frame and provides correlations only between quantitative variables. It is useful for quickly glancing at the size of the correlations between many pairs of variables or all correlations with a particular variable. Further analysis should be done on pairs of interest using associate.

Note: if Spearmans' rank correlations are computed, warnings message result indicating that the exact p-value cannot be computed with ties. Running associate will give you an approximate p-value using the permutation procedure.

References

Introduction to Regression and Modeling

Author(s)

Adam Petrie

See Also

cor, associate

Examples

#all pairwise (Pearson) correlations between all quantitative variables data(STUDENT) all_correlations(STUDENT) #Spearman correlations between all quantitative variables and CollegeGPA, sorted by pvalue. #Gives warnings due to ties all_correlations(STUDENT,interest="CollegeGPA",type="spearman",sorted="significance")
  • Maintainer: Adam Petrie
  • License: GPL (>= 2)
  • Last published: 2020-02-21

Useful links