apply - R: f(x) != sapply(x,f) -- bug or feature? -


  & gt; F = function (x) as in. Date (As Character (x), Format = '% Y% M% D') & gt; F (20110606) [1] "2011-06-06" & gt; Sapply (20110606, f) [1] 15131   

Why 2 returned values ​​are not the same I need to apply this function to the dates of a long vector, but I sapply I am not getting dates together!

  & gt; Lapli (20110606, f) [[1]] [1] "2011-06-06" & gt; Unlisted (lapply (20110606, f)) [1] 15131   

sapply is not dismissed alone and does not leave the date of doing so

  & gt; Unclassified (Lapli (20110606, F) [[1]]) [1] 15131 & gt; As a "date" (@ 20110606, F) [1]] [1] "Date"   

@USUSA Ulrich said that no need to use application types for interest Is not

  d> - 20110606 + 0:10 do.call ("c", lapply (d, f))   

one possible The method will be "Do not list the list

Comments