This code produces a nice pairs plot that has a correlation read-out on the middle right:
library(GGally)
ggpairs(esoph[,c(1,4,5)], colour='agegp')
You can get just the correlation square with:
ggally_cor(data=esoph[,c(1,4,5)],
mapping=aes(x=ncases, y=ncontrols, colour='agegp'))
The square contains a correlation per group. Is there any way to get the correlation for the over-all data set to appear as well? If you don't use colour=...
then you get it, but then you don't get the per-group correlations.
The ggpairs() function from the GGally package allows us to build a great scatterplot matrix. Scatterplots of each pair visualized in left side of the plot and Pearson correlation value and significance displayed on the right side.
The ggpairs() function of the GGally package allows to build a great scatterplot matrix. Scatterplots of each pair of numeric variable are drawn on the left part of the figure. Pearson correlation is displayed on the right. Variable distribution is available on the diagonal.
I can now verify that this works with GGally_0.4.4
with R version 3.0.1 (2013-05-16)
on
Platform: x86_64-pc-linux-gnu (64-bit)
library(GGally)
ggally_cor(data=esoph[,c(1,4,5)],
mapping=aes(x=ncases, y=ncontrols, colour='agegp'))
See that the overall correllation appears at the top and is consistent with the number I get from this command:
ggally_cor(data=esoph[,c(1,4,5)],
mapping=aes(x=ncases, y=ncontrols))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With