add mean line to ggplot

后端 未结 1 875
不知归路
不知归路 2021-01-12 20:19

I\'d like to build on this example of conditioning line color on slope to add a line for the mean (line from mean t=1 to mean t=2).

library(dplyr)
set.seed(2         


        
相关标签:
1条回答
  • 2021-01-12 21:18

    I didn't get the error you describe (with ggplot2 v 2.2.0), but in order to get the desired result I did have to override the grouping you specified in the main plot:

    stat_summary(fun.y=mean,geom="line",lwd=2,aes(group=1))
    
    0 讨论(0)
提交回复
热议问题