title: Fitting a line to the mean values of a multilevel variable using geom_smooth
body: <p>I have this <a href="https://www.dropbox.com/s/ga42rg8ch3hd9fy/datos.csv?dl=0" rel="nofollow noreferrer">dataframe</a>.</p>
  <p>I create a plot representing on the y-axis &quot;value&quot; and on the x-axis each of the levels of &quot;Column_S&quot;, which contains levels from S1 to S10. All this grouped by &quot;VS&quot; and &quot;Inst&quot; (with a facet_grid) and &quot;Estatus&quot; with colour.</p>
  <pre><code>na.omit(data) %&gt;% 
    group_by(VS,Estatus,Inst, Columna_S) %&gt;% 
    summarise(media = mean(value), 
              desvio = sd(value),                             
              error_est = desvio / sqrt(n()),            
              intervalo_sup = media + (2*error_est),      
              intervalo_inf = media - (2*error_est)) -&gt; stats
  
  ggplot() +  
    geom_errorbar(
      data = stats,   
      aes(x = Columna_S,
          ymin = intervalo_inf,
          ymax = intervalo_sup,
          color = Estatus   
      ), width = 0.4 )+
    geom_point(data = stats,
               aes(x = Columna_S,
                   y = media,
               color = Estatus))+
    facet_grid(Inst ~ VS, scales = &quot;free&quot;) +
    theme_classic()  
  </code></pre>
  <p>However, instead of an independent point for each mean, I'd like to use <code>geom_smooth</code> to plot a line (plus standard error) that fits the means along the x-axis.</p>
  <p>I have tried the code below, but it is not generating the desired outcome.</p>
  <pre><code>na.omit(data) %&gt;% 
    ggplot(aes(x=Columna_S,y=value,colour=Estatus, na.rm = TRUE) ) +
    geom_smooth(aes(fill=Estatus,na.rm = TRUE)) +
    scale_y_continuous(breaks = seq(0,100, by=25), limits=c(0,100))+
    facet_grid(Institution~Value_system, scales = &quot;free&quot;)+
    theme_classic()  
  </code></pre>