当前位置:网站首页>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"
)
边栏推荐
- enumrate的start属性的坑
- TIPC introduction 1
- sql left join 主表限制条件写在on后面和写在where后面的区别
- Redis exceeds the maximum memory error oom command not allowed when used memory & gt; ' maxmemory'
- 基于Hardhat和Openzeppelin开发可升级合约(二)
- Iii. Système de démarrage et d'horloge à puce
- TIPC messaging3
- ros缺少catkin_pkg
- 基于Hardhat编写合约测试用例
- 在连接mysql数据库的时候一直报错
猜你喜欢
vant tabs组件选中第一个下划线位置异常
II Stm32f407 chip GPIO programming, register operation, library function operation and bit segment operation
Jinshanyun - 2023 Summer Internship
TDSQL|就业难?腾讯云数据库微认证来帮你
Never forget, there will be echoes | hanging mirror sincerely invites you to participate in the opensca user award research
Redis超出最大内存错误OOM command not allowed when used memory &gt; 'maxmemory'
Mmrotate rotation target detection framework usage record
Pit of the start attribute of enumrate
2022年4月17日五心红娘团队收获双份喜报
Principe du contrat évolutif - delegatecall
随机推荐
Approximate sum count (approximate
QT获取某个日期是第几周
Rest (XOR) position and thinking
Xiao Sha's pain (double pointer
Astparser parsing class files with enum enumeration methods
Win11 arm system configuration Net core environment variable
Introduction to interface debugging tools
RPA advanced (II) uipath application practice
III Chip startup and clock system
mysql 基本语句
在连接mysql数据库的时候一直报错
Homer forecast motif
Tdsql | difficult employment? Tencent cloud database micro authentication to help you
Solve the problem of data blank in the quick sliding page of the uniapp list
ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)
Is the stock account given by qiniu business school safe? Can I open an account?
Verilog 和VHDL有符号数和无符号数相关运算
可升级合约的原理-DelegateCall
CTF record
TIPC messaging3