title: Understanding dates a plotting with ggplot2 in R
body: <p>I have a CSV file called <em>gdata.csv</em>, with data like:</p>
  
  <pre><code>id,date,totKm,eLiter,euros,liters,km
  1,24-04-2010,23678,1.180,42.00,35.59,450
  2,16-05-2010,24058,1.200,43.00,35.83,380
  3,27-05-2010,24488,1.160,44.00,37.93,430
  4,12-06-2010,24960,1.180,45.00,38.14,472
  </code></pre>
  
  <h1>With ggplot2</h1>
  
  <p>I just want to plot <code>date</code> and <code>eliter</code> in a <strong>line char</strong> with <strong>ggplot2</strong>, with this code:</p>
  
  <pre><code>x_date &lt;- as.Date(gdata$date, format = "%d-%m-%Y")
  ggplot(eliter, aes(x_date, eliter)) + geom_line()
  </code></pre>
  
  <p>But, it returns this error related with the class:
  <em>Error: ggplot2 doesn't know how to deal with data of class numeric</em> </p>
  
  <p>I have tried to make a <code>data.frame</code> but it stills returns the error:</p>
  
  <pre><code>d &lt;- data.frame(xdate = x_date, yeliter=gdata$eLiter)
  ggplot(d$xdate, aes(d$xdate, d$yeliter)) + geom_line()
  </code></pre>
  
  <p><em>Error: ggplot2 doesn't know how to deal with data of class Date</em></p>
  
  <h1>With plot</h1>
  
  <p>I have managed to do this with plot() function:</p>
  
  <pre><code>plot(gdata$eLiter~as.Date(gdata$date, "%d-%m-%Y"), type = "s", xlab="Date",ylab="€/Liter", main="€/liter trend", col='blue')
  </code></pre>
  
  <p>And it works fine! But I can not do it with ggplot.</p>
  
  <p>Could anyone help me?</p>
  
  <p>Thank you very much.</p>