Reputation: 11
I'm constructing my own graph by following the codes in a tutorial:
library(ggpubr)
data("ToothGrowth")
ggbarplot(ToothGrowth, x = "dose", y = "len",
add = c("mean_se", "jitter"),
color = "supp", palette = "jco",
position = position_dodge(0.8))
I want to show the number of observation on each column (on the bottom or on the top), together with the error bar and significance. Could anyone use ToothGrowth as an example to plot like this?
Upvotes: 1
Views: 1884
Reputation: 47350
You can try this :
ggbarplot(ToothGrowth, x = "dose", y = "len",
add = c("mean_se", "jitter"),
color = "supp", palette = "jco",
position = position_dodge(0.8)) +
geom_text(aes(x = factor(dose),
y = 0,
label = paste("n =",len,"\n"),
group = supp),
aggregate(. ~ dose + supp,ToothGrowth,length),
position = position_dodge(.8))
I didn't find how to plot one error bar for each group with this package, and i'm not sure if it's possible, by simplifying the interface with such package you also lose flexibility.
Upvotes: 1