Given a POSIXct date time, how do you extract the first day of the month for aggregation?
library(lubridate) full.date <- ymd_hms(\"2013-01-01 00:00:21\"
I don't see a reason to use lubridate:
full.date <- as.POSIXct("2013-01-11 00:00:21", tz="GMT") monthStart <- function(x) { x <- as.POSIXlt(x) x$mday <- 1 as.Date(x) } monthStart(full.date) #[1] "2013-01-01"