Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
你们知道,如何使用包“lubridate”在一个时间间隔内获得每周的第一天?
我知道我也可以使用“seq.Date”生成,但是现在我已经生成了一个时间间隔并想稍后将它与“%within%”一起使用,我想只使用这个间隔并获取每个时间间隔一周。
library(lubridate) dates <- seq(Sys.Date() - 100, Sys.Date(), by = "1 days") week.ids <- floor_date(dates, "week")
现在dates将有过去 100 天中的每一天,并且week.ids将在dates. 因此,week.ids向量提供了足够的信息来按周对日期进行分组。
dates
week.ids