title: Extract parts of timestamp
body: <p>I have some datasets where animals have been logged each 5th second. the data are stored in postgis and I am using R to analyse and plot the data. I would like to ad on the plots some markers showing the position for each hour. I am pulling subsets of the dataset into R making a data frame having among  other information the timestamp and x and y coordinates for each point. </p>
  
  <p>a part of summary() of my data set (total approx 10000 rows):</p>
  
  <pre><code> id             datetime                        date           
  Min.   :2664295   Min.   :2009-08-21 05:00:04   Min.   :2009-08-21  
  1st Qu.:2666819   1st Qu.:2009-08-21 08:30:15   1st Qu.:2009-08-21  
  Median :2669342   Median :2009-08-21 12:00:03   Median :2009-08-21  
  Mean   :2669342   Mean   :2009-08-21 11:30:10   Mean   :2009-08-21  
  3rd Qu.:2671866   3rd Qu.:2009-08-21 14:22:44   3rd Qu.:2009-08-21  
  Max.   :2674390   Max.   :2009-08-21 16:59:58   Max.   :2009-08-21  
  
   lokalitet             cowid           x                y          
  Length:10          Min.   :553   Min.   :455329   Min.   :6712350  
  Class :character   1st Qu.:553   1st Qu.:455718   1st Qu.:6712744  
  Mode  :character   Median :553   Median :456154   Median :6713068  
                     Mean   :553   Mean   :456011   Mean   :6713074  
                     3rd Qu.:553   3rd Qu.:456274   3rd Qu.:6713470  
                     Max.   :553   Max.   :456361   Max.   :6713596  
  </code></pre>
  
  <p>So, what I would like to do is to subset the data set on datetime where the minute part is 0 and the second part is &lt; 5 (i.e. for the timestamps shown in the summary I would like to have 05:00:04 and 12:00:03. (I know I can do this in postgres, but as the base dataset is quite large (approx 4 M rows) and I have not made an index on partial timestamps, I think it may be better to do this on the subset in R) (and no, as I want to do this a number of times, I do not want to just manually find the first row that matches and then take each 720th row from there on)</p>