1 Star 0 Fork 3

weijiew/R-graph-gallery

forked from 程序员维C社区/graph 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
115-study-correlations-with-a-correlogram.Rmd 4.35 KB
一键复制 编辑 原始数据 按行查看 历史
holtzy 提交于 2019-07-25 02:29 +08:00 . correct ggplot2 and density links
title descriptionMeta descriptionTop sectionText sectionLink DataToVizText DataToVizLink url output
Correlogram with the corrgram library
This post explains how to build a correlogram with the corrgram R package. It provides several reproducible examples with explanation and R code.
This post explains how to build a [correlogram](correlogram.html) with the `corrgram` R package. It provides several reproducible examples with explanation and `R` code.
Correlogram section
correlogram.html
Data to Viz
data-to-viz.com/graph/correlogram.html
199-correlation-matrix-with-ggally
html_document
self_contained mathjax lib_dir template css toc toc_float toc_depth df_print
false
default
libs
template_rgg.html
style.css
true
true
2
paged
```{r global options, include = FALSE} knitr::opts_chunk$set( warning=FALSE, message=FALSE) ```
# Scatterplot matrix with `ggpairs()` *** ```{r thecode, echo=FALSE, out.width = c("33%","33%","33%") , fig.height=7, fig.show="hold"} # Corrgram library library(corrgram) # mtcars dataset is natively available in R # head(mtcars) # First corrgram(mtcars, order=TRUE, lower.panel=panel.shade, upper.panel=panel.pie, text.panel=panel.txt, main="Car Milage Data in PC2/PC1 Order") # Second corrgram(mtcars, order=TRUE, lower.panel=panel.ellipse, upper.panel=panel.pts, text.panel=panel.txt, diag.panel=panel.minmax, main="Car Milage Data in PC2/PC1 Order") # Third corrgram(mtcars, order=NULL, lower.panel=panel.shade, upper.panel=NULL, text.panel=panel.txt, main="Car Milage Data (unsorted)") ``` The `corrgram` package allows to build [correlogram](correlogram.html). The output allows to check the relationship between each pair of a set of numeric variable. Relationship can be visualized with different methods: - `panel.ellipse` to display ellipses - `panel.shade` for coloured squares - `panel.pie` for pie charts - `panel.pts` for scatterplots ```{r thecode, eval=FALSE} ``` # Visualize correlation with `ggcorr()` ***
The `ggcorr()` function allows to visualize the correlation of each pair of variable as a square. Note that the `method` argument allows to pick the correlation type you desire.
```{r thecode2, echo=FALSE, out.width = "100%", fig.height=7} # Quick display of two cabapilities of GGally, to assess the distribution and correlation of variables library(GGally) # Create data data
```{r thecode2, eval=FALSE} ``` # Split by group {#category} ***
It is possible to use [ggplot2](ggplot2-package.html) aesthetics on the chart, for instance to color each category.
```{r thecode3, echo=FALSE, out.width = "100%", fig.height=7} # Quick display of two cabapilities of GGally, to assess the distribution and correlation of variables library(GGally) # From the help page: data(flea) ggpairs(flea, columns = 2:4, ggplot2::aes(colour=species)) ```
```{r thecode3, eval=FALSE} ``` # Change plot types ***
Change the type of plot used on each part of the [correlogram](correlogram.html). This is done with the `upper` and `lower` argument.
```{r thecode4, echo=FALSE, out.width = "100%", fig.height=7} # Quick display of two cabapilities of GGally, to assess the distribution and correlation of variables library(GGally) # From the help page: data(tips, package = "reshape") ggpairs( tips[, c(1, 3, 4, 2)], upper = list(continuous = "density", combo = "box_no_facet"), lower = list(continuous = "points", combo = "dot_no_facet") ) ```
```{r thecode4, eval=FALSE} ```
```{r, echo=FALSE} htmltools::includeHTML("htmlChunkRelatedCorrelation.html") ```
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/weijiew/R-graph-gallery.git
git@gitee.com:weijiew/R-graph-gallery.git
weijiew
R-graph-gallery
R-graph-gallery
master

搜索帮助