How to add a number of observations per group and use group mean in ggplot2 boxplot?

后端 未结 3 1288
余生分开走
余生分开走 2020-11-28 09:50

I am doing a basic boxplot where y=age and x=Patient groups

age <- ggplot(data, aes(factor(group2), age))  + ylim(15, 80) 
age         


        
3条回答
  •  爱一瞬间的悲伤
    2020-11-28 10:33

    Answer to the first problem. To show value above the box you should provide x values as numeric not as level names. So, to plot the value above first value give x=1.

    data(ToothGrowth)
    ggplot(ToothGrowth,aes(supp,len))+geom_boxplot()+
       annotate("text",x=1,y=32,label=30)
    

提交回复
热议问题