Skip to content

Instantly share code, notes, and snippets.

@AlbertRapp
Created February 25, 2023 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlbertRapp/2bac2381563de2cc7141e87e4093e1e1 to your computer and use it in GitHub Desktop.
Save AlbertRapp/2bac2381563de2cc7141e87e4093e1e1 to your computer and use it in GitHub Desktop.
position_dodge.R
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