Programming/R

[R] 4 packages for Correlation Heatmap plot

김해김씨99대손 2023. 6. 21. 17:01
library(ggcorrplot)
library(heatmaply)
library(plotly)
library(corrplot)
library(reshape)

 

 

 

Col <- cor(mtcars)
Col.m <- reshape2::melt(Col)


ggplot(data = Col.m, aes(x=Var1, y=Var2, fill=value)) + 
  geom_tile() +
  geom_text(aes(Var2, Var1, label = round(value,1 )), size = 3) +
  scale_fill_gradient2(low = "red", high = "green",
                       limit = c(-1,1), name="Correlation") +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        panel.background = element_blank())

corrplot::corrplot(cor(mtcars))

 

ggcorrplot::ggcorrplot(cor(mtcars))

 

heatmaply::ggheatmap(cor(mtcars))

 

corr_mat <- ggcorrplot::ggcorrplot(cor(mtcars))
plotly::ggplotly(corr_mat)

 

 

 

 

| Reference

- http://www.sthda.com/english/wiki/correlation-analyses-in-r

- https://towardsdatascience.com/customizable-correlation-plots-in-r-b1d2856a4b05

 

반응형