I am experiencing an issue working with POSIXct objects. With using functions that return POSIXct objects with sapply(), sapply() seems to automatically convert them to numeric.
lapply() seems to maintain the POSIXct class, but when I unlist(), I lose it again.
Is there a way to take advantage of apply() while still using POSIXct? I have a project at work with lots of date-time information, and I'm getting frustrated. Many thanks!
# unwanted POSIXct conversion to numeric
as.POSIXct(Sys.time(), "GMT") %>% rep(5) %>% sapply(function(x) x)
# lapply seems to maintain POSIXct class, but if I unlist(), I lose POSIXct again
as.POSIXct(Sys.time(), "GMT") %>% rep(5) %>% lapply(function(x) x)
as.POSIXct(Sys.time(), "GMT") %>% rep(5) %>% lapply(function(x) x) %>% unlist()