Hello,
floor_date(x, unit = 'weeks') returns the same value (the previous Sunday, in my testing) regardless of what the lubridate.week.start option is set to:
library(lubridate)
options(lubridate.week.start = 7)
wday(ymd('2017-01-02')) # 2
floor_date(ymd('2017-01-02'), unit = 'weeks') # "2017-01-01"
options(lubridate.week.start = 1)
wday(ymd('2017-01-02')) # 1
floor_date(ymd('2017-01-02'), unit = 'weeks') # "2017-01-01"
As the above snippet shows, even though the results of wday(x) change according to lubridate.week.start, the results of floor_date(x, unit = 'weeks') do not. Intuitively, if the week start is set to Sunday, then floor_date() should always return a Sunday; if the option is set to Monday, then the function should always return a Monday, and so on.
I believe the issue is actually due to the update() function also ignoring this option:
options(lubridate.week.start = 7)
update(ymd('2017-01-02'), wday = 1) # "2017-01-01"
wday(ymd('2017-01-01')) # 1
options(lubridate.week.start = 1)
update(ymd('2017-01-02'), wday = 1) # "2017-01-01"
wday(ymd('2017-01-01')) # 7
In the latter case, wday(update(x, wday = 1)) does not give a result of 1, even though we explicitly set wday = 1.
Hello,
floor_date(x, unit = 'weeks')returns the same value (the previous Sunday, in my testing) regardless of what thelubridate.week.startoption is set to:As the above snippet shows, even though the results of
wday(x)change according tolubridate.week.start, the results offloor_date(x, unit = 'weeks')do not. Intuitively, if the week start is set to Sunday, thenfloor_date()should always return a Sunday; if the option is set to Monday, then the function should always return a Monday, and so on.I believe the issue is actually due to the
update()function also ignoring this option:In the latter case,
wday(update(x, wday = 1))does not give a result of1, even though we explicitly setwday = 1.