Environmental data (R airquality)

Correlation heatmap example: air quality with missing values

Spearman correlations of ozone, sun, wind and temperature in New York, 1973, with pairwise n from 111 to 153 and Holm-adjusted asterisks.

Open this example in the editorStart from scratch

Solar.R × Ozone: Spearman ρ = 0.35, n = 111, adjusted p < 0.0010.35*Wind × Ozone: Spearman ρ = −0.59, n = 116, adjusted p < 0.001−0.59*Wind × Solar.R: Spearman ρ = 0.00, n = 146, adjusted p = 0.9910.00Temp × Ozone: Spearman ρ = 0.77, n = 116, adjusted p < 0.0010.77*Temp × Solar.R: Spearman ρ = 0.21, n = 146, adjusted p = 0.0240.21*Temp × Wind: Spearman ρ = −0.45, n = 153, adjusted p < 0.001−0.45*Solar.RWindTempOzoneSolar.RWindSpearman ρ−1−0.500.51
Spearman ρ for daily ozone, solar radiation, wind and temperature; * marks Holm-adjusted p < 0.05.

About this example

The R dataset airquality holds 153 daily readings from New York, May to September 1973 (Chambers et al. 1983). Ozone is missing on 37 days and solar radiation on 7, so each pair uses the days where both values exist: n ranges from 111 (ozone with solar radiation) to 153. The Month and Day columns are left out under Columns.

Ozone rises with temperature (ρ = 0.77) and falls with wind speed (ρ = −0.59). Spearman ρ is used because ozone is right-skewed. Five of the six pairs stay below 0.05 after the Holm adjustment over all six tests; solar radiation and wind do not correlate (ρ = −0.001).

Sources: R documentation: New York Air Quality Measurements (airquality)

The data

OzoneSolar.RWindTempMonthDay
411907.46751
3611887252
1214912.67453
1831311.56254
NANA14.35655
28NA14.96656
232998.66557
199913.85958
81920.16159
NA1948.669510
7NA6.974511
162569.769512
112909.266513
1427410.968514
186513.258515

…and 138 more rows. Open the example to see all of them.

One row per observation. Correlations use the rows where both values are present (pairwise complete) and match R cor and cor.test. Open the example, replace the data with your own, and export the figure as SVG, PDF, PNG or TIFF.

More examples