A heat map encodes data values with colors or shades arranged across a two-dimensional layout. For correlation analysis, each tile represents the relationship between two continuous variables, making strong, weak, and near-zero associations easy to compare. section 2.5.4
Build a correlation heat map in R by preparing the data, reshaping the matrix, and mapping coefficients to tiles:
- Select only continuous variables, such as Age, G, MP, WS, and WS48, because correlation coefficients require continuous data. section 2.5.4
- Pass the selected data to cor() to create a correlation matrix; the matrix repeats each variable pair across two symmetrical positions. section 2.5.4
- Use melt() to convert the matrix into Var1, Var2, and value columns, then use ggplot2 geom_tile() to draw colored cells. section 2.5.4
- Add a diverging fill scale from -1 to 1 and label tiles with rounded coefficients so color and numeric value reinforce each other. section 2.5.4
NBA draft correlations
A correlation heat map of first-round draft data compares Age, games played, minutes played, win shares, and win shares per 48 minutes. The matrix shows, for example, a correlation of about 0.66 between MP and WS48 and about 0.80 between G and WS. These patterns reveal association, not causation: a strong correlation does not prove that one variable influences another. section 2.5.4 section 2.7






