当我尝试使用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'
正如Matt Gibson和Roland所建议的那样,错误与运行旧版本的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.
当然,格式无法解析,因为正如Prem和InfiniteFlashChess所提到的,我把mdy
函数中的月份和日期混淆了。
> mdy('01-15-2018')
[1] "2018-01-15"