# How to Create a Nice Box and Whisker Plot in R

#### How to Create a Nice Box and Whisker Plot in R

R codes are provided for creating a nice box and whisker plot in R with summary table under the plot.

# Load required R packages
library(ggpubr)

# Data preparation
df <- ToothGrowth
head(df)
##    len supp dose
## 1  4.2   VC  0.5
## 2 11.5   VC  0.5
## 3  7.3   VC  0.5
## 4  5.8   VC  0.5
## 5  6.4   VC  0.5
## 6 10.0   VC  0.5
# Create basic boxplot
ggboxplot(df, x = "dose", y = "len", add = "jitter")

# Create a box plot with summary table
ggsummarystats(
df, x = "dose", y = "len", add = "jitter",
color = "supp", palette = "npg",
ggfunc = ggboxplot
)

Version: Français