title: R - ggplot geom_smooth facet_grid CI not showing
body: <p>I am having a hard time understanding why the confidence intervals are not showing with my data. When I reproduce my code on another dataset, the code seems to work fine. For example, on <code>mtcars</code></p>
  
  <p>The code is </p>
  
  <pre><code>mtols = mtcars %&gt;% group_by(am) %&gt;% do(lm0 = lm(disp ~ mpg*gear + vs, data=.)) %&gt;% 
                 augment(., lm0) %&gt;% 
                 mutate(ymin=.fitted-1.96*.se.fit, ymax=.fitted+1.96*.se.fit) 
  </code></pre>
  
  <p>To generate the plot </p>
  
  <pre><code>mtols %&gt;% ggplot(aes(mpg, .fitted) ) + 
    geom_smooth(data = mtols, aes(mpg, .fitted, group = gear, colour = gear, fill= gear), method="lm") +
    theme_minimal() + facet_grid(~am)
  </code></pre>
  
  <p>I get the confidence intervals. </p>
  
  <p>However this doesn't work with my data. Could someone help me figure out what goes wrong here ? I would be very grateful. </p>
  
  <p>I compute the <code>OLS</code> with </p>
  
  <pre><code>dt = new %&gt;% group_by(day) %&gt;% do(lm0 = lm(y ~ year*class, data=.)) %&gt;% augment(., lm0) %&gt;% 
    mutate(ymin=.fitted-1.96*.se.fit, ymax=.fitted+1.96*.se.fit) 
  
  dt$year = as.numeric(as.character(dt$year)) 
  </code></pre>
  
  <p>The plot, (this is an example with few cases, but the results is the same with the whole dataset) </p>
  
  <pre><code>dt %&gt;% ggplot(aes(year, .fitted) ) + 
    geom_smooth(data = dt, aes(year, .fitted, group = class, colour = class, fill= class), method="lm") + 
    theme_bw() + facet_grid(~day) 
  </code></pre>
  
  <p>The <code>CI</code> are not showing. </p>
  
  <p><a href="https://i.stack.imgur.com/ZVANI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZVANI.png" alt="enter image description here"></a></p>
  
  <p>Any clue what I am doing wrong here ? </p>
  
  <p>Strangely, when I don't use the <code>facet_grid</code> here, the <code>CI</code> work perfectly </p>
  
  <p><a href="https://i.stack.imgur.com/5kgR0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5kgR0.png" alt="enter image description here"></a></p>
  
  <pre><code>dt %&gt;% ggplot(aes(year, .fitted) ) + 
    geom_smooth(data = dt, aes(year, .fitted, group = class, colour = class, fill= class), method="lm") + 
    theme_bw()
  </code></pre>
  
  <p>A sample of my data </p>
  
  <pre><code>library(broom) 
  library(dplyr)
  library(ggplot2)
  
  new = structure(list(id = structure(c(844084L, 114510L, 14070410L, 
  942483L, 13190105L, 421369L, 301384L, 251789L, 11011210L, 11280408L, 
  278575L, 310410L, 16260105L, 11110815L, 18260101L, 14260501L, 
  10580L, 15090210L, 19140410L, 13230615L, 246511L, 20040812L, 
  14260114L, 287623L, 16090620L, 20131007L, 835743L, 453390L, 395808L, 
  363617L), label = "Household identifier", class = c("labelled", 
  "integer")), year = structure(c(1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 
  2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 
  2L, 2L, 1L, 1L, 1L, 1L), .Label = c("2000", "2015"), class = "factor"), 
  day = c("Weekend", "Weekend", "Weekend", "Weekdays", "Weekdays", 
  "Weekend", "Weekdays", "Weekend", "Weekend", "Weekdays", 
  "Weekend", "Weekdays", "Weekdays", "Weekend", "Weekend", 
  "Weekdays", "Weekdays", "Weekend", "Weekdays", "Weekdays", 
  "Weekdays", "Weekend", "Weekend", "Weekend", "Weekend", "Weekend", 
  "Weekend", "Weekdays", "Weekdays", "Weekdays"), class = structure(c(1L, 
  1L, 2L, 2L, 1L, 2L, 2L, 4L, 2L, 2L, 3L, 2L, 1L, 4L, 1L, 3L, 
  2L, 3L, 2L, 4L, 2L, 1L, 3L, 2L, 1L, 4L, 3L, 2L, 4L, 1L), .Label = c("Higher Managerial", 
  "Lower Managerial", "Intermediate", "Manual and Routine"), class = "factor"), 
  y = c(270, 730, 180, 0, 0, 290, 90, 650, 510, 0, 10, 200, 
  200, 180, 0, 0, 140, 260, 110, 740, 260, 0, 390, 610, 0, 
  0, 500, 0, 10, 170)), class = "data.frame", row.names = c(NA, 
  -30L), .Names = c("id", "year", "day", "class", "y"))
  </code></pre>