当前位置:网站首页>How to Create a Beautiful Plots in R with Summary Statistics Labels
How to Create a Beautiful Plots in R with Summary Statistics Labels
2022-07-02 09:38:00 【小宇2022】
library(tidyverse)
library(rstatix)
library(ggpubr)
# Demo data
data("ToothGrowth")
df <- ToothGrowth
df$dose <- as.factor(df$dose)
# Add random QC column
set.seed(123)
qc <- rep(c("pass", "fail"), 30)
df$qc <- as.factor(sample(qc, 60))
# Inspect the data
head(df)
# Basic plot
ggsummarystats(
df, x = "dose", y = "len",
ggfunc = ggboxplot, add = "jitter"
)

library(tidyverse)
library(rstatix)
library(ggpubr)
# Demo data
data("ToothGrowth")
df <- ToothGrowth
df$dose <- as.factor(df$dose)
# Add random QC column
set.seed(123)
qc <- rep(c("pass", "fail"), 30)
df$qc <- as.factor(sample(qc, 60))
# Inspect the data
head(df)
# Color by groups
ggsummarystats(
df, x = "dose", y = "len",
ggfunc = ggboxplot, add = "jitter",
color = "dose", palette = "npg"
)

# Grouped plots
ggsummarystats(
df, x = "dose", y = "len",
ggfunc = ggboxplot, add = "jitter",
color = "supp", palette = "npg"
)
# Change plot type to violin
ggsummarystats(
df, x = "dose", y = "len",
ggfunc = ggviolin, add = c("jitter", "median_iqr"),
color = "supp", palette = "npg"
)

library(tidyverse)
library(rstatix)
library(ggpubr)
# Demo data
data("ToothGrowth")
df <- ToothGrowth
df$dose <- as.factor(df$dose)
# Add random QC column
set.seed(123)
qc <- rep(c("pass", "fail"), 30)
df$qc <- as.factor(sample(qc, 60))
# Inspect the data
head(df)
# Compute summary statistics
summary.stats <- df %>%
group_by(dose) %>%
get_summary_stats() %>%
select(dose, n, median, iqr)
summary.stats
# Create a boxplot
bxp <- ggboxplot(
df, x = "dose", y = "len", add = "jitter",
ggtheme = theme_bw()
)
# Visualize the summary statistics
summary.plot <- ggsummarytable(
summary.stats, x = "dose", y = c("n", "median", "iqr"),
ggtheme = theme_bw()
) +
clean_table_theme()
# Combine the boxplot and the summary statistics plot
ggarrange(
bxp, summary.plot, ncol = 1, align = "v",
heights = c(0.80, 0.20)
)
# Create barplot
ggsummarystats(
df, x = "dose", y = "len",
ggfunc = ggbarplot, add = c("jitter", "median_iqr"), position = position_dodge(),
color = "supp", palette = "npg"
)

library(tidyverse)
library(rstatix)
library(ggpubr)
# Demo data
data("ToothGrowth")
df <- ToothGrowth
df$dose <- as.factor(df$dose)
# Add random QC column
set.seed(123)
qc <- rep(c("pass", "fail"), 30)
df$qc <- as.factor(sample(qc, 60))
# Inspect the data
head(df)
# Create line plots
ggsummarystats(
df, x = "dose", y = "len",
ggfunc = ggline, add = c("jitter", "median_iqr"),
color = "supp", palette = "npg"
)
边栏推荐
- What is the relationship between digital transformation of manufacturing industry and lean production
- deepTools对ChIP-seq数据可视化
- 对毕业季即将踏入职场的年轻人的一点建议
- mysql链表数据存储查询排序问题
- Importerror: impossible d'importer le nom « graph» de « graphviz»
- PowerBI中导出数据方法汇总
- TIPC Getting Started6
- Order by注入
- 制造业数字化转型和精益生产什么关系
- Mmrotate rotation target detection framework usage record
猜你喜欢

由粒子加速器产生的反中子形成的白洞

II Stm32f407 chip GPIO programming, register operation, library function operation and bit segment operation

Why does LabVIEW lose precision in floating point numbers

A white hole formed by antineutrons produced by particle accelerators

可昇級合約的原理-DelegateCall

Solve the problem of data blank in the quick sliding page of the uniapp list

念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研

Importerror: impossible d'importer le nom « graph» de « graphviz»

MTK full dump grab

What is the relationship between digital transformation of manufacturing industry and lean production
随机推荐
C#基于当前时间,获取唯一识别号(ID)的方法
高德根据轨迹画线
ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)
Astparser parsing class files with enum enumeration methods
LVM operation
Why does LabVIEW lose precision in floating point numbers
Basic usage of MySQL in centos8
php 根据经纬度查询距离
I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)
From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
sqlite 修改列类型
基于Hardhat和Openzeppelin开发可升级合约(二)
PowerBI中导出数据方法汇总
On April 17, 2022, the five heart matchmaker team received double good news
mmrotate旋转目标检测框架使用记录
SQLite modify column type
可升级合约的原理-DelegateCall
Functional interfaces and method references
STM32 single chip microcomputer programming learning
TIPC messaging3
