I would like to display the number of observations per group in a graph that reports the value of a variable over time.
this is my current script, thank you in advance!
ggplot(df, aes(x=time_nrp, y=lac, color=as.factor(outcome)))+ 
  geom_point(stat="summary", fun=mean, size=4)+
  geom_line(stat="summary", fun=mean, aes(group=as.factor(outcome)))+
  stat_summary(fun.data=mean_se, geom="errorbar", width=0.01)+
  xlab("NRP Time (hours)")+
  ylab("Lactate (mmol/l)")+
  geom_text(aes(y = 0,label = lac),vjust = 0)+
  theme_bw()+
  ggtitle("Panel A")+ 
  theme(plot.title = element_text(hjust=0.5))+
  theme(text=element_text(family="Helvetica", size=20))+
  scale_color_manual(name="Outcome", 
                     breaks=c("0", "1"),
                     labels=c("Negative", "Positive"),
                     values = c("#E12000", "#002F80"))
this is an example of my data, I would like to display the number of observations per group next to the time point of the two lines indicating the groups.
id  group time lactate     
 1     A   1   1.2
 1     A   2   1.1
 1     A   3   1.3
 2     B   1   0.8
 2     B   2   0.7
 2     B   3   0.9
 3     A   1   0.7
 3     A   2   0.9
 3     A   3   1.3
 4     B   1   0.5
 4     B   2   0.6
 4     B   3   0.7 
 
    
