How to calculate a decimal month in R in a particular year?
<p>If I have a date, say <code>"2014-05-13"</code> and I want to calculate the month in decimal,  I would do this: </p>

<pre><code>5 + 13/31 = 5.419355
</code></pre>

<p>How would it be possible in R to take a vector of dates and turn in it into a "month decimal" vector? </p>

<p>For example: </p>

<pre><code>dates = c("2010-01-24", "2013-04-08", "2014-03-05", "2013-03-08", "2014-02-14", 
          "2004-01-28", "2006-02-21", "2013-03-28", "2013-04-01", "2006-02-14", 
          "2006-01-28", "2014-01-19", "2012-03-12", "2014-01-30", "2005-04-17")

library(lubridate)
month(dates) + day(dates)/31
</code></pre>

<p>As you can see, it would be wrong to put "31" as the diviser since the number of days differ depending on the month, and sometimes year (leap years). </p>

<p>So what would be the best solution?</p>