title: How to periodize years into dates?
body: <p>I'd like to go from this:</p>
  
  <pre><code>  years
   -------
    1994
    2001
     .
     .
  </code></pre>
  
  <p>To this:</p>
  
  <pre><code>int dates
   ------
    8793    # 1994-01-28
    8824    # 1994-02-28
    8852    # 1994-03-28
    8883    # 1994-04-28
    8913    # 1994-05-28
    8944    # 1994-06-28
    8974    # 1994-07-28
    9005    # 1994-08-28
    9036    # 1994-09-28
    9066    # 1994-10-28
    9097    # 1994-11-28
    9127    # 1994-12-28
   11350    # 2001-01-28
   11381    # 2001-02-28
   11409    # 2001-03-28
   11440    # 2001-04-28
   11470    # 2001-05-28
   11501    # 2001-06-28
   11531    # 2001-07-28
   11562    # 2001-08-28
   11593    # 2001-09-28
   11623    # 2001-10-28
   11654    # 2001-11-28
   11684    # 2001-12-28
     .
     .
  </code></pre>
  
  <p>i.e. periodizing each year into 12 dates (the 28th each month of that year) as 1970-base integers.</p>
  
  <p>What is the most efficient way of doing this?</p>
  
  <p>My attempt is painfully slow!</p>
  
  <pre><code>require(data.table)
  
  # Sample data
  dt &lt;- data.table(year=c(1994,2001)) # edit
  
  # Create results table
  data &lt;- data.table(dates=integer())
  
  for (i in 1:12) {
      temp &lt;- dt
      temp$dates &lt;- as.integer(as.Date(paste(temp$year, "-", sprintf( "%02d",i),"-28", sep="")))
      temp &lt;- subset(temp, select=dates)
      data &lt;- rbind(temp,data)
  }
  
  # Sort
  data &lt;- data[with(data, order(dates)),]
  </code></pre>