R lubridate:为什么我会收到“未知时区”错误?

时间:2017-12-25 09:17:34

标签: r lubridate

当我尝试使用mdy函数时,为什么会出现“未知时区”错误?

> library(lubridate)

Attaching package: ‘lubridate’

The following object is masked from ‘package:base’:

    date

> mdy('15-01-2018')
Error in as.POSIXlt.POSIXct(x, tz) : 
  (converted from warning) unknown timezone 'zone/tz/2017c.1.0/zoneinfo/Asia/Hong_Kong'

1 个答案:

答案 0 :(得分:2)

根据Matt GibsonRoland的建议, 该错误与运行旧版本的R。

有关

我在2017年8月左右安装了R版本3.4.1, 当我的电脑运行macOS 10.12 Sierra时。 2017年11月左右,我将macOS更新为10.13 High Sierra。 安装R版本3.4.3后, unknown timezone错误不再出现。

> library(lubridate)

Attaching package: ‘lubridate’

The following object is masked from ‘package:base’:

    date

> mdy('15-01-2018')
[1] NA
Warning message:
All formats failed to parse. No formats found. 

当然,格式无法解析, 因为PremInfiniteFlashChess提到的, 我在mdy函数中混淆了月份和日期。

> mdy('01-15-2018')
[1] "2018-01-15"