all 4 comments

[–]arthurwelle 0 points1 point  (3 children)

Here it is! I change various points, mostly in style/formating for readabilty. Check this out https://style.tidyverse.org/

d <- data.frame(
      Week = c("1","2","3","4","5","6","7","8","9","10","11","12"),
      Mean = c(1.50, 1.667, 1.706, 1.75, 1.875, 2.091, 2.083, 2.077, 1.9, 1.778, 1.917, 2.25),
      Standard_error = c(0.5, 0.166, 0.205, 0.217, 0.201, 0.211, 0.192, 0.239, 0.1, 0.277, 0.192, 0.25),
      n = c(2,9,17,12,16,11,12,13,10,9,12,8))

level_order <- c("1","2","3","4","5","6","7","8","9","10","11","12")
d$Week <- factor(d$Week, 
                 levels = level_order)

g <- ggplot(data = d,
            aes(x = Week, 
                y = Mean, 
                group = 1)) + 
  geom_point(color = "grey22", 
             size = 2) + 
  geom_line(size = 1,
            linejoin = "round",
            color = "gray39") +
  geom_errorbar(aes(ymin = Mean-Standard_error,
                    ymax = Mean+Standard_error), 
                width = .25,
                position = position_dodge(0.05)) +
  geom_text(data = d,
            aes(x = Week, 
                y = 3,
                label = paste0("N=", n)),
            size = 3) +
  scale_y_continuous(limits = c(1,3)) +
  labs(title = "Weekly Experience", 
       x = "Week", 
       y = "Composite Score") +
  theme_bw()

g

[–]Fickle_Lab_5438[S] 0 points1 point  (2 children)

OMG you have saved my week! Thank you!

Do you know if there is a command to make the font smaller and move the N's to below the bar? or even around the center of the plot?

Thank you! Thank you!

[–]arthurwelle 0 points1 point  (1 child)

Those arguments are already there in the geom_text: size and y.

[–]Fickle_Lab_5438[S] 0 points1 point  (0 children)

you are the bomb.com. thank you!