当我尝试使用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'
答案 0 :(得分:2)
根据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"