title: ggplot2 line chart gives "geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?"
body: <p>With this data frame ("df"):</p>
  
  <pre><code>year pollution
  1 1999 346.82000
  2 2002 134.30882
  3 2005 130.43038
  4 2008  88.27546
  </code></pre>
  
  <p>I try to create a line chart like this:</p>
  
  <pre><code>  plot5 &lt;- ggplot(df, aes(year, pollution)) +
             geom_point() +
             geom_line() +
             labs(x = "Year", y = "Particulate matter emissions (tons)", title = "Motor vehicle emissions in Baltimore")
  </code></pre>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>geom_path: Each group consist of only one observation. Do you need to
    adjust the group aesthetic?</p>
  </blockquote>
  
  <p>The chart appears as a scatter plot even though I want a line chart. I tried to replace <code>geom_line()</code> with <code>geom_line(aes(group = year))</code> but that didn't work. </p>
  
  <p>In an answer I was told to convert year to a factor variable. I did and the problem persists. This is the output of <code>str(df)</code> and <code>dput(df)</code>:</p>
  
  <pre><code>'data.frame':   4 obs. of  2 variables:
   $ year     : num  1 2 3 4
   $ pollution: num [1:4(1d)] 346.8 134.3 130.4 88.3
    ..- attr(*, "dimnames")=List of 1
    .. ..$ : chr  "1999" "2002" "2005" "2008"
  
  structure(list(year = c(1, 2, 3, 4), pollution = structure(c(346.82, 
  134.308821199349, 130.430379885892, 88.275457392443), .Dim = 4L, .Dimnames = list(
      c("1999", "2002", "2005", "2008")))), .Names = c("year", 
  "pollution"), row.names = c(NA, -4L), class = "data.frame")
  </code></pre>