当前位置:网站首页>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"
)
边栏推荐
- 数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
- QT meter custom control
- K-Means Clustering Visualization in R: Step By Step Guide
- Never forget, there will be echoes | hanging mirror sincerely invites you to participate in the opensca user award research
- Mmrotate rotation target detection framework usage record
- Develop scalable contracts based on hardhat and openzeppelin (I)
- A sharp tool for exposing data inconsistencies -- a real-time verification system
- 制造业数字化转型和精益生产什么关系
- deepTools对ChIP-seq数据可视化
- Eight sorting summaries
猜你喜欢
GGHIGHLIGHT: EASY WAY TO HIGHLIGHT A GGPLOT IN R
R HISTOGRAM EXAMPLE QUICK REFERENCE
RPA进阶(二)Uipath应用实践
Eight sorting summaries
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
JS -- take a number randomly from the array every call, and it cannot be the same as the last time
excel表格中选中单元格出现十字带阴影的选中效果
HOW TO CREATE AN INTERACTIVE CORRELATION MATRIX HEATMAP IN R
可升级合约的原理-DelegateCall
Power Spectral Density Estimates Using FFT---MATLAB
随机推荐
YYGH-10-微信支付
Power Spectral Density Estimates Using FFT---MATLAB
bedtools使用教程
Is the stock account given by qiniu business school safe? Can I open an account?
动态内存(进阶四)
电脑无缘无故黑屏,无法调节亮度。
C # method of obtaining a unique identification number (ID) based on the current time
On April 17, 2022, the five heart matchmaker team received double good news
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
基于Hardhat和Openzeppelin开发可升级合约(二)
揭露数据不一致的利器 —— 实时核对系统
Analyse de l'industrie
Order by injection
SSRF
Seriation in R: How to Optimally Order Objects in a Data Matrice
Tiktok overseas tiktok: finalizing the final data security agreement with Biden government
FLESH-DECT(MedIA 2021)——一个material decomposition的观点
PHP query distance according to longitude and latitude
通讯录的实现(文件版本)
K-Means Clustering Visualization in R: Step By Step Guide