当前位置:网站首页>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"
)
边栏推荐
- I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)
- 在连接mysql数据库的时候一直报错
- ASTParser 解析含有emum 枚举方法的类文件的踩坑记
- Mmrotate rotation target detection framework usage record
- RPA进阶(二)Uipath应用实践
- MySql存储过程游标遍历结果集
- Jenkins installation
- ros缺少xacro的包
- Jinshanyun - 2023 Summer Internship
- From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
猜你喜欢

TIPC addressing 2

Redis超出最大内存错误OOM command not allowed when used memory &gt; 'maxmemory'

I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)

TIPC messaging3

RPA进阶(二)Uipath应用实践

RPA advanced (II) uipath application practice

Map set assignment to database

VS2019代码中包含中文内容导致的编译错误和打印输出乱码问题

Thanos Receiver

ctf 记录
随机推荐
Tick Data and Resampling
tidb-dm报警DM_sync_process_exists_with_error排查
可昇級合約的原理-DelegateCall
Attribute acquisition method and operation notes of C # multidimensional array
从攻击面视角,看信创零信任方案实践
微信小程序利用百度api达成植物识别
Complement (Mathematical Simulation
TIPC Getting Started6
Win11 arm system configuration Net core environment variable
Never forget, there will be echoes | hanging mirror sincerely invites you to participate in the opensca user award research
Jenkins installation
MySQL basic statement
QT获取某个日期是第几周
Wechat applet uses Baidu API to achieve plant recognition
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
PYQT5+openCV项目实战:微循环仪图片、视频记录和人工对比软件(附源码)
sql left join 主表限制条件写在on后面和写在where后面的区别
Array splitting (regular thinking
电脑无缘无故黑屏,无法调节亮度。
PLC-Recorder快速监控多个PLC位的技巧
