当前位置:网站首页>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 11:50:00 【Xiaoyu 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"
)
边栏推荐
- Dynamic memory (advanced 4)
- Easyexcel and Lombok annotations and commonly used swagger annotations
- The position of the first underline selected by the vant tabs component is abnormal
- Develop scalable contracts based on hardhat and openzeppelin (I)
- HOW TO EASILY CREATE BARPLOTS WITH ERROR BARS IN R
- Cluster Analysis in R Simplified and Enhanced
- How to Add P-Values onto Horizontal GGPLOTS
- excel表格中选中单元格出现十字带阴影的选中效果
- Amazon cloud technology community builder application window opens
- 基于Hardhat和Openzeppelin开发可升级合约(二)
猜你喜欢

2022年4月17日五心红娘团队收获双份喜报

How to Easily Create Barplots with Error Bars in R

The position of the first underline selected by the vant tabs component is abnormal

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

mysql链表数据存储查询排序问题

制造业数字化转型和精益生产什么关系

The computer screen is black for no reason, and the brightness cannot be adjusted.

Webauthn - official development document

JS -- take a number randomly from the array every call, and it cannot be the same as the last time

Wechat applet uses Baidu API to achieve plant recognition
随机推荐
b格高且好看的代码片段分享图片生成
【2022 ACTF-wp】
电脑无缘无故黑屏,无法调节亮度。
Is it safe to open a stock account online? I'm a novice, please guide me
pgsql 字符串转数组关联其他表,匹配 拼接后原顺序展示
MySQL比较运算符IN问题求解
HOW TO EASILY CREATE BARPLOTS WITH ERROR BARS IN R
excel表格中选中单元格出现十字带阴影的选中效果
Fabric.js 3个api设置画布宽高
基于 Openzeppelin 的可升级合约解决方案的注意事项
MySQL comparison operator in problem solving
What week is a date obtained by QT
Order by注入
HOW TO CREATE AN INTERACTIVE CORRELATION MATRIX HEATMAP IN R
程序员成长第六篇:如何选择公司?
Summary of data export methods in powerbi
【2022 ACTF-wp】
揭露数据不一致的利器 —— 实时核对系统
基于Hardhat编写合约测试用例
map集合赋值到数据库
