平日因素减少8小时

时间:2018-01-21 02:58:55

标签: r posixct

我试图添加一个因子来标记我的数据中的星期几,但新的"工作日"专栏似乎关闭了8个小时。 "日期时间"字段具有以下形式:%Y-%m-%d%H:%M:%S',tz =' GMT'。我在下面提供了示例数据以及我的代码。看看我做错了什么以及如何解决它?

代码:

##Weekday variables
WeekdayVar<-icartdffill
WeekdayVar$Weekday<-as.factor(weekdays(as.Date(WeekdayVar$DateTime, "%Y-%m-%d", tz="GMT")))

示例数据:

dput(droplevels(icartdffill[1:50,]))
structure(list(OrderCnt = c(1L, 1L, 0L, 0L, 0L, 2L, 5L, 12L, 
16L, 30L, 27L, 21L, 23L, 27L, 37L, 36L, 35L, 30L, 27L, 17L, 8L, 
2L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 2L, 6L, 9L, 19L, 28L, 27L, 28L, 
22L, 29L, 41L, 35L, 43L, 42L, 27L, 16L, 10L, 2L, 1L, 0L, 0L, 
0L), DateTime = structure(c(1398931200, 1398934800, 1398938400, 
1398942000, 1398945600, 1398949200, 1398952800, 1398956400, 1398960000, 
1398963600, 1398967200, 1398970800, 1398974400, 1398978000, 1398981600, 
1398985200, 1398988800, 1398992400, 1398996000, 1398999600, 1399003200, 
1399006800, 1399010400, 1399014000, 1399017600, 1399021200, 1399024800, 
1399028400, 1399032000, 1399035600, 1399039200, 1399042800, 1399046400, 
1399050000, 1399053600, 1399057200, 1399060800, 1399064400, 1399068000, 
1399071600, 1399075200, 1399078800, 1399082400, 1399086000, 1399089600, 
1399093200, 1399096800, 1399100400, 1399104000, 1399107600), class = c("POSIXct", 
"POSIXt"))), .Names = c("OrderCnt", "DateTime"), row.names = c(NA, 
50L), class = "data.frame")

0 个答案:

没有答案