r - 从POSIXct对象中提取星期数

标签 r date lubridate

lubridate中有一个函数可以提取星期数吗?
我已经尝试过搜索,但是找不到任何可以达到目的的东西。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.

最佳答案

使用strftime:

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

关于r - 从POSIXct对象中提取星期数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25866436/

相关文章:

r - 从 R 中的年、月和周数据中插入年月日

r - 如何从 rgbif 中的搜索中保存出现数据

javascript - 如何创建自定义 JS 函数以将 plotly 图像复制到 R shiny 中的剪贴板

Mysql 将 double 或 int 转换为日期或月份

php - HTML5日期输入,保存到MySQL数据库

r - 在日期序列中查找月份的最后一天

r - R 是否在分配时复制 S4 类(class)中未评估的插槽?

r - 从线性回归函数 lm 中获取误差值

java - 使用正则表达式分割字符串

r - 在一系列日期中识别第三个星期五