Jokel Meyer
unread,Feb 19, 2012, 3:25:48 AM2/19/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggplot2
Dear ggplot2 users!
I would like to create a facetted bar plot and then indicate
significance using a little asterix. Plotting works fine but I am not
sure how to add the asterix on top of the bar were dat$p<0.05 ?
Many thanks for your help!
Here is my code:
library(ggplot2)
# some dummy data
dat <- data.frame(name=c("a","b","a","c","a","b","d","c"),
val=c(1,-1.2,2.2,0.9,-0.7,2.4,-2.3,0.6),
sd=c(0.2,0.3,0.25,0.2,0.25,0.6,0.56,0.2),
p=c(0.09,0.1,0.02,0.1,0.2,0.001,0.001,0.6),
grp=c("A","A","B","B","C","C","C","C"))
ggplot(aes(x=name,y=val,width=0.5,ymin=val-sd,ymax=val+sd),data=dat)
+geom_bar(stat="identity",position="dodge") +
geom_errorbar(stat="identity",position="dodge") + facet_grid(~grp,
scales="free_x",space="free",margin=FALSE)