Created
February 25, 2023 09:36
-
-
Save AlbertRapp/2bac2381563de2cc7141e87e4093e1e1 to your computer and use it in GitHub Desktop.
position_dodge.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
tooth_data <- ToothGrowth |> | |
as_tibble() |> | |
mutate(dose = factor(dose)) | |
tooth_data_relabeled <- tooth_data |> | |
mutate( | |
supp = if_else( | |
supp == 'VC', 'Vitamin C supplement', 'Orange Juice' | |
) | |
) | |
tooth_data_relabeled |> | |
ggplot( | |
aes(y = len, x = supp, fill = dose) | |
) + | |
geom_point( | |
size = 6, | |
alpha = 0.75, | |
shape = 21, | |
col = 'black', | |
position = position_dodge( | |
width = 0.5 | |
) | |
) + | |
theme_minimal(base_size = 20) + | |
labs( | |
x = 'Supplement', | |
y = 'Length', | |
fill = 'Dose', | |
title = 'Length of tooth growth cells after supplements' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment