title: mapply and SIMPLIFY and not stripping classes
body: <p>I am having an issue using lapply and mapply returning data.  Namely that mapply / lapply returns a list of lists.  And if I "simplify" the call it strips out the class information.  </p>
  
  <p>For example:</p>
  
  <pre><code>library(lubridate)
  
  addBusDays &lt;- function(d, dd) {
   d 
  }
  
  # start with datframe
  dates &lt;- c(ymd('2013-03-04'), ymd('2013-03-07'))
  my.df &lt;- data.frame(n=c(1,2), d=dates)
  
  mapply(addBusDays, my.df$d, 1, SIMPLIFY=F)
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>[[1]]
  [1] "2013-03-03 19:00:00 EST"
  
  [[2]]
  [1] "2013-03-06 19:00:00 EST"
  
  class(mapply(addBusDays, my.df$d, 1, SIMPLIFY=F)[[1]]
  [1] "POSIXct" "POSIXt"
  </code></pre>
  
  <p>It looks like it is returning a list of lists, which is workable but I don't lke the solution.  Allowing the function to simplify strips the POSIX class:</p>
  
  <pre><code>mapply(addBusDays, my.df$d, 1, SIMPLIFY=T)
  class(mapply(addBusDays, my.df$d, 1, SIMPLIFY=T))
  
  &gt; mapply(addBusDays, my.df$d, 1, SIMPLIFY=T)
  [1] 1362355200 1362614400
  &gt; class(mapply(addBusDays, my.df$d, 1, SIMPLIFY=T))
  [1] "numeric"
  </code></pre>
  
  <p>this looks to return a single list, but strips out the class info.  ANy help / ideas?</p>
  
  <p>Working orking off of Gavin's suggestions</p>
  
  <pre><code>library(lubridate)
  
  addBusDays &lt;- function(d, dd) {
    d 
  }
  
  # start with datframe
  dates &lt;- c(ymd('2013-03-04'), ymd('2013-03-07'))
  my.df &lt;- data.frame(n=c(1,2), d=dates)
  my.df$d.2 &lt;- as.POSIXct(mapply(addBusDays, my.df$d, 2, SIMPLIFY=T), origin="1970-01-01")
  
  typeof(my.df$d)
  class(my.df$d)
  mode(my.df$d)
  typeof(my.df$d.2)
  class(my.df$d.2)
  mode(my.df$d.2)
  
  my.df
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>&gt; my.df
    n                   d        d.2
  1 1 2013-03-03 19:00:00 2013-03-04
  2 2 2013-03-06 19:00:00 2013-03-07
  </code></pre>
  
  <p>The technique is shifting the day by 1 - it shouldn't in this example as the function returns the date passed in...  Other than that the class etc seems spot on. </p>
  
  <p>And I my eyes are fooling me - my problem is in loading the data frame - not with Gavin's solution.</p>