当前位置:网站首页>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"
)
边栏推荐
- 【2022 ACTF-wp】
- 基于 Openzeppelin 的可升级合约解决方案的注意事项
- bedtools使用教程
- Introduction to interface debugging tools
- excel表格中选中单元格出现十字带阴影的选中效果
- What is the relationship between digital transformation of manufacturing industry and lean production
- [multithreading] the main thread waits for the sub thread to finish executing, and records the way to execute and obtain the execution result (with annotated code and no pit)
- Order by injection
- GGPLOT: HOW TO DISPLAY THE LAST VALUE OF EACH LINE AS LABEL
- 念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
猜你喜欢
HOW TO ADD P-VALUES ONTO A GROUPED GGPLOT USING THE GGPUBR R PACKAGE
【2022 ACTF-wp】
Data analysis - Matplotlib sample code
ESP32音频框架 ESP-ADF 添加按键外设流程代码跟踪
GGPLOT: HOW TO DISPLAY THE LAST VALUE OF EACH LINE AS LABEL
Power Spectral Density Estimates Using FFT---MATLAB
Basic usage of MySQL in centos8
Attribute acquisition method and operation notes of C # multidimensional array
A white hole formed by antineutrons produced by particle accelerators
JS -- take a number randomly from the array every call, and it cannot be the same as the last time
随机推荐
基于Hardhat和Openzeppelin开发可升级合约(一)
Implementation of address book (file version)
[cloud native] 2.5 kubernetes core practice (Part 2)
制造业数字化转型和精益生产什么关系
How to Create a Beautiful Plots in R with Summary Statistics Labels
How to Visualize Missing Data in R using a Heatmap
pgsql 字符串转数组关联其他表,匹配 拼接后原顺序展示
C # method of obtaining a unique identification number (ID) based on the current time
YYGH-9-预约下单
QT meter custom control
HOW TO EASILY CREATE BARPLOTS WITH ERROR BARS IN R
Visualization of chip SEQ data by deeptools
Redis超出最大内存错误OOM command not allowed when used memory &gt; 'maxmemory'
Industry analysis
to_ Bytes and from_ Bytes simple example
TDSQL|就业难?腾讯云数据库微认证来帮你
JS -- take a number randomly from the array every call, and it cannot be the same as the last time
可昇級合約的原理-DelegateCall
Principe du contrat évolutif - delegatecall
PX4 Position_ Control RC_ Remoter import