matthieugomez / statar

R package for data manipulation — inspired by Stata's API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enrich `floor_date` function

ywhcuhk opened this issue · comments

@matthieugomez Could you add an additional parameter that determines start or end of the unit specified in floor_date function?

An example would be:

d = as.Date('1992-03-15')
floor_date(d, 'month', 'end') # gives 1992-03-31
floor_date(d, 'month', 'start') # gives 1992-03-01

Thanks!

The function is directly taken from hadley/lubridate, so you should try to make a request on this package. I have just rewritten it so that flooring to quarter is allowed.

Also note you can obtain the option end by

floor_date(d, 'month') + months(1) - days(1)

Actually, two more things: