当前位置:网站首页>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"
)
边栏推荐
- php 二维、多维 数组打乱顺序,PHP_php打乱数组二维数组多维数组的简单实例,php中的shuffle函数只能打乱一维
- Programmer growth Chapter 6: how to choose a company?
- SSRF
- Enter the top six! Boyun's sales ranking in China's cloud management software market continues to rise
- 【多线程】主线程等待子线程执行完毕在执行并获取执行结果的方式记录(有注解代码无坑)
- On April 17, 2022, the five heart matchmaker team received double good news
- What is the relationship between digital transformation of manufacturing industry and lean production
- 基于Hardhat和Openzeppelin开发可升级合约(一)
- Order by injection
- How to Visualize Missing Data in R using a Heatmap
猜你喜欢

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

On April 17, 2022, the five heart matchmaker team received double good news

Flesh-dect (media 2021) -- a viewpoint of material decomposition

ESP32音频框架 ESP-ADF 添加按键外设流程代码跟踪

Develop scalable contracts based on hardhat and openzeppelin (II)

Power Spectral Density Estimates Using FFT---MATLAB

PgSQL string is converted to array and associated with other tables, which are displayed in the original order after matching and splicing

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

RPA advanced (II) uipath application practice

Summary of data export methods in powerbi
随机推荐
vant tabs组件选中第一个下划线位置异常
程序员成长第六篇:如何选择公司?
预言机链上链下调研
Summary of flutter problems
基于Hardhat和Openzeppelin开发可升级合约(一)
Data analysis - Matplotlib sample code
A sharp tool for exposing data inconsistencies -- a real-time verification system
GGPLOT: HOW TO DISPLAY THE LAST VALUE OF EACH LINE AS LABEL
RPA进阶(二)Uipath应用实践
Visualization of chip SEQ data by deeptools
Research on and off the Oracle chain
Mmrotate rotation target detection framework usage record
[visual studio 2019] create MFC desktop program (install MFC development components | create MFC application | edit MFC application window | add click event for button | Modify button text | open appl
Esp32 stores the distribution network information +led displays the distribution network status + press the key to clear the distribution network information (source code attached)
Is it safe to open a stock account online? I'm a novice, please guide me
ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)
亚马逊云科技 Community Builder 申请窗口开启
PHP query distance according to longitude and latitude
excel表格中选中单元格出现十字带阴影的选中效果
Dynamic memory (advanced 4)
