How corrr works with correlation data frames (cor_df)
mainUnlike base R's cor() which returns a correlation matrix, corrr focuses on creating and working with data frames of correlations (cor_df). This allows you to use tidyverse tools (like dplyr, tidyr, and ggplot2) to explore correlations.
When you call correlate(), it returns a tbl with the additional class cor_df. The structure includes:
- A
termcolumn (representing the variable name). - Correlation values for other variables.
- Standardized variances (the matrix diagonal) are set to
NAso they can be easily ignored in calculations or visualizations.
Note: As of version 0.4.3, the first column is named term. In previous versions, it was named rowname.
# Example of the resulting structure
x <- correlate(d)
class(x)
#> [1] "cor_df" "tbl_df" "tbl" "data.frame"