title: Filtering a data frame by date in R
body: <p>In R I have imported data from a tab-separated text file into a data.frame.
  The table looks like this:</p>
  
  <pre><code>latitude longitude date         temperature
  -------- --------- ------       -----------
  50.45989 15.363366 "2014-01-29" -14.4
  50.00911 15.323255 "2014-01-30" -10.2
  50.88900 15.440032 "2014-01-29" -14.4
  </code></pre>
  
  <p>When I write the command:</p>
  
  <pre><code>str(mydata)
  </code></pre>
  
  <p>I get the following result:</p>
  
  <pre><code>'data.frame':   211931 obs. of  10 variables:
  $ latitude      : num  50.8 50.8 50.8 50.8 50.8 ...
  $ longitude: num  15.6 15.6 15.6 15.6 15.6 ...
  $ date : Factor w/ 581 levels "2012-07-01","2012-07-02",..: 1 2 3 4 5 6 7 8 9 10 ...
  $ temperature  : num  -14.4.6 -15.5 -10.1 -9.2 NA ...
  </code></pre>
  
  <p>I want to create a subset of the data frame that only contains rows with date equal to 29th January 2014. How do I do this in R?</p>
  
  <p>I tried the commands:</p>
  
  <pre><code>datefilter = as.Date("2014-01-29")
  selection = mydata[mydata[date]==datefilter]
  </code></pre>
  
  <p>But R complains about: Cannot convert type "factor" to "date".</p>