从POSIXct对象中提取周数

时间:2021-08-16 07:49:30

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.

在lubridate中有一个函数来提取周数吗?我试图寻找它,但找不到任何有用的目的。

The week() function does something different.

week()函数做了不同的事情。

Description

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.

日期时间必须是POSIXct,POSIXlt,Date,chron,yearmon,yearqtr,zoo,zooreg,timeDate,xts,> its,ti,jul,timeSeries和fts对象。周数是在日期和1月1日之间发生的完整七天期间的数量加一。 isoweek返回ISO 8601系统中出现的一周,该系统使用了一个reoccuring闰周。

1 个解决方案

#1


10  

Use strftime:

dateRange <- c("2008-10-01","2008-12-01") 
x <- as.POSIXlt(dateRange) 
strftime(x,format="%W") 
[1] "39" "48" 

#1


10  

Use strftime:

dateRange <- c("2008-10-01","2008-12-01") 
x <- as.POSIXlt(dateRange) 
strftime(x,format="%W") 
[1] "39" "48"