R Language Date and Time Go to First Day of the Month


Example

Let's say we want to go to the first day of a given month:

date <- as.Date("2017-01-20")

> as.POSIXlt(cut(date, "month"))
[1] "2017-01-01 EST"