0

My apologies for my ineptitude... it's been a while since I had my R stats class and I've been trying to figure this out all day. I'm having some difficulty including percentages on the bars in my plot. Is it possible to do so with the script I already have?

proj <- Master_List_for_R_Studio
#data prep
proj$Location <- as.factor(proj$Location)
head(proj, 3)
proj$Host <- as.factor(proj$Host)
head(proj,3)

#compute summary stats
proj.summary2 <- proj %>%
  group_by(Location, Host) %>%
  summarise(
    std.error = std.error(prv_aspido),
    prv_aspido = mean(prv_aspido)
  )
proj.summary2

#plot
asp.ab3 <-ggplot(proj.summary2, aes(Location, prv_aspido)) +
  geom_col(aes(fill = Host), position = position_dodge(0.8), width = 0.7) +
  labs(y= "Aspido.sp Abundance") +
  geom_errorbar(
    aes(ymin = prv_aspido-std.error, ymax = prv_aspido+std.error, group = Host),
    width = 0.2, position = position_dodge(0.8)
  ) +
  scale_y_continuous(labels = scales::percent)
asp.ab3

With this script, I get the following plot, but I'd like to include percentages. I've also been referring to Sebastian Sauer

Current Plot

r2evans
  • 141,215
  • 6
  • 77
  • 149
apucci
  • 1
  • FYI, code fences need to be on lines by themselves, as in `\`\`\`\n`, no code on the same line at all. I've made a suggested edit, please read https://stackoverflow.com/editing-help and https://meta.stackexchange.com/a/22189 – r2evans Apr 18 '22 at 01:56
  • 1
    Likely a duplicate of https://stackoverflow.com/q/40249943/3358272, does that answer your question? – r2evans Apr 18 '22 at 01:58
  • 1
    If you could share your data using `dput(proj.summary2)`, we can reproduce your problem. – Quinten Apr 18 '22 at 10:34

0 Answers0