I spent some time this morning learning about how R thinks about dates in R. I found this website to be a useful guide.
Imagine that your data are dates in a standard format [YEAR-MONTH-DAY (as in 2011-23-04) is one such format] and you want a vector of the dates that are the first day in the month of your data set. You might, for example, be interested in this (as an intermediate calculation) because you wish to match some S&P 500 returns data to monthly data. Frustratingly, the S&P 500 returns data do not report on the weekends or on holidays when the exchange is closed.
Here’s a function that will do return a vector of first-days-of-the-month if you give it a vector of dates. Maybe you will find this useful.