从POSIXct对象中提取周数 [英] Extract week number from POSIXct object
问题描述
在 lubridate
中有提取周号的功能吗?
我试图搜索,但找不到任何用于此目的的东西。
Is there a function in lubridate
to extract the week number?
I've tried to search for that but couldn't find anything which serves the purpose.
week()
函数有所不同。
描述
日期时间必须是POSIXct,POSIXlt,Date,chron,yearmon,yearqtr,zoo,zooreg,timeDate,xts,> it,ti,jul,timeSeries和fts对象。周数是在日期和1月1日之间发生的完整的七天期间
的数量,加上一个。 isoweek返回周,因为
将出现在ISO 8601系统中,该系统使用重新引用闰年。
Date-time must be a POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, timeDate, xts, > its, ti, jul, timeSeries, and fts objects. Weeks is the number of complete seven day periods that have occured between the date and January 1st, plus one. isoweek returns the week as it would appear in the ISO 8601 system, which uses a reoccuring leap week.
推荐答案
使用 strftime
:
dateRange <- c("2008-10-01","2008-12-01")
x <- as.POSIXlt(dateRange)
strftime(x,format="%W")
[1] "39" "48"
这篇关于从POSIXct对象中提取周数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!