Skip to content

Instantly share code, notes, and snippets.

@juanchiem
Last active March 12, 2021 17:25
Show Gist options
  • Save juanchiem/009c0f6bcff8930c21105049851b81a1 to your computer and use it in GitHub Desktop.
Save juanchiem/009c0f6bcff8930c21105049851b81a1 to your computer and use it in GitHub Desktop.
library("tidyverse")
cebada <- tibble::tribble(
~trt, ~trat_id, ~bq, ~rend_seco,
1, "Test", 1, 7527.0792385361,
2, "Allegro 1000", 1, 7834.14085058484,
3, "Azoxy Pro 400", 1, 7105.33761425004,
1, "Test", 2, 7073.4451399919,
2, "Allegro 1000", 2, 8198.71524530747,
3, "Azoxy Pro 400", 2, 7312.61874119017,
1, "Test", 3, 8263.95165943664,
2, "Allegro 1000", 3, 8342.18786257771,
3, "Azoxy Pro 400", 3, 7980.40317044249
)
cebada %>%
group_by(trt) %>%
summarise(rend_seco = mean(rend_seco)) %>%
mutate(respuesta = ((rend_seco-first(rend_seco))/first(rend_seco)*100) %>%
round(1) %>%
paste0(ifelse(. >= 0, "+", ""), ., "%")) -> cebada_sum
cebada %>%
ggplot()+
aes(x=factor(trt), y=rend_seco)+
geom_bar(stat = 'summary', fun = 'mean') +
scale_x_discrete(labels = unique(cebada$trat_id))+
stat_summary(fun.data=mean_cl_boot, geom="errorbar", width = 0.1) +
geom_point(shape = 21)+
geom_hline(aes(yintercept =
cebada_sum %>%
dplyr::filter(trt==1) %>%
pull(rend_seco)),
linetype=2, col="gray30")+
theme_bw()+
geom_text(data = cebada_sum,
aes(label = respuesta, x = trt, y = rend_seco, vjust= 1.2),
size =3, col = "white")+
labs(x = "", y = "kg/ha")+
theme(axis.text.x = element_text(angle = 60, vjust = 1, hjust=1))
@juanchiem
Copy link
Author

image

@juanchiem
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment