ggplot2 - Indicating the statistically significant difference in bar graph USING R -
this repeat of question asked here: indicating statistically important difference in bar graph asked r instead of python.
my question simple. want produce barplots in r, using ggplot2 if possible, indication of important difference between different bars, e.g. produce this. have had search around can't find question asking same thing.
you can utilize geom_path()
, annotate()
similar result. illustration have determine suitable position yourself. in geom_path()
4 numbers provided little ticks connecting lines.
df<-data.frame(group=c("a","b","c","d"),numb=c(12,24,36,48)) g<-ggplot(df,aes(group,numb))+geom_bar(stat="identity") g+geom_path(x=c(1,1,2,2),y=c(25,26,26,25))+ geom_path(x=c(2,2,3,3),y=c(37,38,38,37))+ geom_path(x=c(3,3,4,4),y=c(49,50,50,49))+ annotate("text",x=1.5,y=27,label="p=0.012")+ annotate("text",x=2.5,y=39,label="p<0.0001")+ annotate("text",x=3.5,y=51,label="p<0.0001")
r ggplot2 bar-chart
No comments:
Post a Comment