ggplot选项以直方图显示平均值

时间:2020-08-16 08:27:41

标签: r ggplot2 plot geom-text

我已经使用下面的代码生成了一个图histogram snap

ggplot(data,aes(x=AGE,fill=ARMC))+
  geom_histogram(position="dodge",bins=10)+
  geom_vline(data=k,aes(xintercept=grp.mean,color=ARMC),linetype="dashed")+
  theme(legend.position="top")+
  facet_wrap(~ARMC)

我的平均值是(名为K的数据集) ARMC平均值 1 75.20930 2 74.38095 3 75.66667

在输出捕捉中,我想显示沿网格线的平均值。 我尝试使用grom_text geom_text(k,mapping=aes(fontface=2,x=ARMC,y=round(grp.mean,2),hjust=0, vjust=0),但收到的错误是错误:离散值提供给连续刻度

有人可以帮我解决这个问题吗?

0 个答案:

没有答案