title: Divide values in data frame according to date range in another data frame
body: <p>I have two dataframes. Dataframe <code>data</code> one has two columns: one contains <code>ymd</code> dates, and the other values:</p>
  
  <pre><code>        date value
  1 2009-10-23  1100
  2 2009-05-01  5000
  3 2010-01-13  3050
  4 2010-07-24  2700
  5 2009-06-16  2600
  </code></pre>
  
  <p>My second dataframe (named <code>factors</code>) also has two columns: another <code>ymd</code> date, and a coefficient. Here, for each month of each year, I <em>always</em> have two specific dates: the 1st and 15th of each month. This is how the data frame looks (I only added <em>some</em> dates on this minimal example, but there shouldn't be any 'jumps': I have continued data in a 10-year period):</p>
  
  <pre><code>         date coeff
  1  2009-05-01  2.00
  2  2009-05-15  3.00
  3  2009-06-01  2.50
  4  2009-06-15  4.00
  5  2009-10-01  3.65
  6  2009-10-15  4.80
  7  2010-01-01  2.40
  8  2010-01-15  1.90
  9  2010-07-01  5.20
  10 2010-07-15  4.30
  </code></pre>
  
  <p>The dataframes are ready to use on this fiddle: <a href="http://rextester.com/MOIY96065" rel="nofollow noreferrer">http://rextester.com/MOIY96065</a></p>
  
  <p><strong>My problem</strong></p>
  
  <p>I need to create a new column in dataframe 1 (named <code>data</code>) where this column is <code>data$value / factors$coeff</code> following a condition: it must use the <code>coeff</code> with the previous closest <code>date</code> value.</p>
  
  <p>For example: <code>date$value[1]</code> should be divided by <code>factors$coeff[6]</code> (the value on October 15th), but <code>date$value[2]</code> should be divided by <code>factors$coeff[1]</code> (the value on May 1st).</p>
  
  <p>My <code>factors</code> dataframe is ordered by date. I've been using <code>lubridate</code> to parse the dates from string type, but I don't know how can I make this work.</p>