I would like to generate a heatmap/correlation map in R. I have explored various packages, such as corrplot, ggcorrplot and pheatmap, but I found it difficult to get where I wanted.
As an example, using mtcars, I would like to generate a heatmap like below. Specifically:
- Compare mpg only against disp, hp, drat and wt using Spearman correlations.
- Do these comparisons for
cyl=4,cyl=6andcyl=8separately. - Calculate the Spearman p values.
- Draw heatmap, where tile colors represent Spearman correlation coefficients (r) and p values are printed on each tile.
Desired result similar to this:

I would appreciate help. Thank you.
