Machine Learning - Data visualization with R (III)
This article continues presenting different techniques that can be used to communicate data or information by encoding it in graphs.
Correlogram
Correlogram is a graph of the correlation matrix. It is useful to highlight the most correlated variables.
# Load packages
install.packages("ggplot2");library("ggplot2");
install.packages("corrplot");library("corrplot");
install.packages("RColorBrewer");library("RColorBrewer");
#Color
corrplot(cor(mtcars), method="color", type="upper", order="hclust",
addCoef.col="black", col=brewer.pal(n=8, name="RdYlBu"),
tl.col="black", tl.srt=45, sig.level=0.2, insig = "blank", diag=FALSE)
#Pies
corrplot(cor(mtcars), method="pie", type="upper", order="hclust",
col=brewer.pal(n=8, name="RdYlBu"),
tl.col="black", tl.srt=45, sig.level=0.2, insig="blank", diag=FALSE)
#Ellipses
corrplot(cor(mtcars), method="ellipse", type="upper", order="hclust",
col=brewer.pal(n=8, name="RdYlBu"),
tl.col="black", tl.srt=45, sig.level=0.2, insig="blank", diag=FALSE)
#Circles, ignore low significance, create 2 groups.
res <- cor.mtest(mtcars, conf.level=.95)
corrplot(cor(mtcars), method="circle",
order="hclust", addrect=2,
p.mat=res, sig.level=0.2,
col=brewer.pal(n=8, name="RdYlBu"),
tl.col="black", tl.srt=45, diag=FALSE)
Many More Graphs and Charts
There is a wide range of charts supported by the already existing powerful R libraries. Here you have some of them:
- Base R Graphs/Charts
- ggplot2 at The R graph Gallery. See also Top 50 ggplot2 Visualizations.
- Plotly R Library
Try it out, share your experience and provide feedback!