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

问题描述 投票:0回答:1

当我尝试使用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'
r lubridate
1个回答
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"
© www.soinside.com 2019 - 2024. All rights reserved.