Nothing
## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
message = FALSE,
warning = FALSE,
dpi = 150,
fig.align = "center",
out.width = "80%"
)
## -----------------------------------------------------------------------------
library(ggcorrplot)
## -----------------------------------------------------------------------------
data(mtcars)
corr <- round(cor(mtcars), 1)
corr[1:5, 1:5]
## -----------------------------------------------------------------------------
p.mat <- cor_pmat(mtcars)
p.mat[1:5, 1:5]
## ----basic, fig.show = "hold", out.width = "48%", fig.align = "default"-------
ggcorrplot(corr)
ggcorrplot(corr, method = "circle")
## ----circle-scale-------------------------------------------------------------
ggcorrplot(corr, method = "circle", circle.scale = 0.6)
## ----hc-----------------------------------------------------------------------
ggcorrplot(corr, hc.order = TRUE, outline.color = "white")
## ----hc-rect------------------------------------------------------------------
ggcorrplot(corr, hc.order = TRUE, hc.rect = 3, outline.color = "white")
## ----triangle, fig.show = "hold", out.width = "48%", fig.align = "default"----
ggcorrplot(corr, hc.order = TRUE, type = "lower", outline.color = "white")
ggcorrplot(corr, hc.order = TRUE, type = "upper", outline.color = "white")
## ----mixed, fig.width = 6.5, fig.height = 6-----------------------------------
ggcorrplot(corr,
lower.method = "number", upper.method = "circle",
cell.grid = TRUE, show.legend = FALSE
)
## ----lab, fig.width = 6, fig.height = 5.6-------------------------------------
ggcorrplot(corr, hc.order = TRUE, type = "lower", lab = TRUE)
## ----lab-style, fig.width = 6, fig.height = 5.6-------------------------------
ggcorrplot(cor(mtcars[, 1:6]),
lab = TRUE, lab_size = 3.5,
leading.zero = FALSE, nsmall = 2,
type = "lower"
)
## ----insig-pch, fig.width = 6, fig.height = 5.6-------------------------------
ggcorrplot(corr, hc.order = TRUE, type = "lower", p.mat = p.mat)
## ----insig-blank, fig.width = 6, fig.height = 5.6-----------------------------
ggcorrplot(corr, hc.order = TRUE, type = "lower", p.mat = p.mat, insig = "blank")
## ----insig-stars, fig.width = 6, fig.height = 5.6-----------------------------
ggcorrplot(corr, p.mat = p.mat, insig = "stars")
## ----sig-stars, fig.width = 6, fig.height = 5.6-------------------------------
ggcorrplot(corr,
type = "lower", p.mat = p.mat,
lab = TRUE, insig = "stars"
)
## ----colors, fig.width = 6, fig.height = 5.6----------------------------------
ggcorrplot(corr,
hc.order = TRUE, type = "lower", outline.color = "white",
colors = c("#6D9EC1", "white", "#E46726")
)
## ----theme, fig.width = 6, fig.height = 5.6-----------------------------------
ggcorrplot(corr,
hc.order = TRUE, type = "lower",
ggtheme = ggplot2::theme_minimal,
tl.col = "gray30", tl.srt = 90,
colors = c("#003C67", "white", "#8F2727")
)
## ----compose, fig.width = 6, fig.height = 5.8---------------------------------
library(ggplot2)
ggcorrplot(corr, hc.order = TRUE, type = "lower", outline.color = "white") +
labs(
title = "Correlations among mtcars variables",
caption = "Hierarchically clustered"
) +
theme(plot.title = element_text(face = "bold"))
## ----save, eval = FALSE-------------------------------------------------------
# p <- ggcorrplot(corr, hc.order = TRUE, lab = TRUE)
# ggplot2::ggsave("correlogram.png", p, width = 7, height = 6, dpi = 300)
## ----pmat, eval = FALSE-------------------------------------------------------
# cor_pmat(mtcars, method = "spearman")
## ----session------------------------------------------------------------------
sessionInfo()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.