First day of the month from a POSIXct date time using lubridate

前端 未结 4 726
孤城傲影
孤城傲影 2020-12-10 01:19

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\"         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 01:45

    i have another solution :

    first.of.month <- full.date - mday(full.date) + 1
    

    but it needs the library 'lubridate' or 'date.table'(aggregation with data.table)

提交回复
热议问题