Skip to content
Prev 306157 / 398506 Next

POSIXct coerced into numeric when filling a data frame

Try this; does away with the 'for', but have to convert back to
POSIXct since sapply strips off the class:
[1] "2011-10-30 15:45:00 EDT"
+     , first = unix2POSIXct(sapply(x, function(d) d[as.Date(d) ==
"2011-10-30"][1]))
+     , second = unix2POSIXct(sapply(x, function(d) d[as.Date(d) ==
"2011-10-30"][2]))
+     )
ID               first              second
a  a 2011-10-30 15:45:00 2011-10-30 16:00:00
b  b 2011-10-30 15:30:00 2011-10-30 15:45:00


On Mon, Sep 24, 2012 at 10:30 AM, Arnaud Duranel
<arnaud.duranel.09 at ucl.ac.uk> wrote: