当前位置:网站首页>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"
)
边栏推荐
- From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
- ROS lacks catkin_ pkg
- Always report errors when connecting to MySQL database
- The difference between SQL left join main table restrictions written after on and where
- 2022年4月17日五心红娘团队收获双份喜报
- Basic usage of MySQL in centos8
- TIPC protocol
- Astparser parsing class files with enum enumeration methods
- php 根据经纬度查询距离
- 高德根据轨迹画线
猜你喜欢
II Stm32f407 chip GPIO programming, register operation, library function operation and bit segment operation
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
Map set assignment to database
tqdm的多行显示与单行显示
Mmrotate rotation target detection framework usage record
What is the relationship between digital transformation of manufacturing industry and lean production
ctf 记录
MySQL比较运算符IN问题求解
[idea] use the plug-in to reverse generate code with one click
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
随机推荐
Astparser parsing class files with enum enumeration methods
php 根据经纬度查询距离
What is the relationship between digital transformation of manufacturing industry and lean production
Verilog 和VHDL有符号数和无符号数相关运算
Thanos Receiver
LVM operation
Solve the problem of data blank in the quick sliding page of the uniapp list
Precautions for scalable contract solution based on openzeppelin
Xiao Sha's pain (double pointer
Homer forecast motif
Homer预测motif
Rest (XOR) position and thinking
Indexer in C #
[idea] use the plug-in to reverse generate code with one click
Compilation errors and printout garbled problems caused by Chinese content in vs2019 code
ROS lacks xacro package
flutter 问题总结
JS——每次调用从数组里面随机取一个数,且不能与上一次为同一个
2022年遭“挤爆”的三款透明LED显示屏
SSRF