Boxplots in R with ggplot and geom_boxplot() [R- Graph Gallery Tutorial]

preview_player
Показать описание
In this tutorial I show you how to create Boxplots in R with geom_boxplot() and ggplot().

The examples are based in the R-Graph Gallery. I show how boxplots can be used to visualize multiple different distributions at once. I will also walk you through many different parameters and function arguments that allow you to customize your boxplots in many ways.

⏱ Time Stamps ⌚
0:00 - Intro and video overview
1:31 - Boxplot theory and outlier rule
5:30 - Basic boxplots with geom_boxplot()
6:40 - Function arguments and notching
8:50 - Change the colors of boxplots
9:57 - Highlight a single boxplot
10:54 - Grouping boxplots
12:08 - Adding the average with stat_summary()
12:55 - Adding points with geom_jitter and geom_dotplot
14:06 - Adding boxplots in the margins of a scatterplot
14:36 - Final example and outro animation

External Links:

Background Music:
Outro Animation:
AA-VFX Motion Backgrounds
Рекомендации по теме
Комментарии
Автор

If you want to download the R code from this video you can do this here in my free skool community:

TheDataDigest
Автор

This has been the most helpful video while making figures for my dissertation!! Thank you

aquarianfog
Автор

Thanks man :3 I´m from Colombia and your videos are amazing!

nicolastovar
Автор

Below is the code I used for the thumbnail (overlay of boxplot over density plots):

red <- rbeta(200, shape1 = 0.3, shape2 = 2) * 4
green <- rnorm(1000, mean = 2)
orange <- rnorm(1000, mean = 3.5, sd = 0.5)

xx <- data.frame(group = rep(c("red", "green", "orange"), times = c(200, 1000, 1000)),
value = c(red, green, orange),
box = rep(c(0.4, 0.7, 1.0), times = c(200, 1000, 1000)))

col_vector <- c("#72F281", "#357BF0", "#F0624D")

xx %>%
ggplot(aes(x=value, color = group, fill = group)) +
geom_density(alpha = 0.4) +
geom_boxplot(aes(x = value, y = box, alpha = 0.8), color = "black") +
theme_void() +
theme(legend.position="none") +
labs(x = "", y = "") +
scale_color_manual(values = col_vector) +
scale_fill_manual(values = col_vector)

TheDataDigest
Автор

but how can I avoid duplicating the circles on outliers? for example we can see for a single data a red circle and also a black one. Thank you and so useful video!

erichideki
Автор

Hi! I seem to be struggling to produce the boxplots per row using the ggplot. My dataframe consists of 10k values in each row that I need to visualise as an individual boxplot. Any suggestions?

martastaff
Автор

Dont use pipe %>%, let your code easy to understantable by everybody even python propgramers etc..
ggplot2(data = data, aes =(x=names...) is better all needed info are encapsulated inside the function : data and attributes

WahranRai
join shbcf.ru