POSIXct:as.POSIXct("2008-03-30 02:00:00",格式="%Y-%m-%d%H:%M:%S")失败是否是R中的错误?

1 statistics posix r posixct datetime-conversion

转换为POSIXct时会发生非常奇怪的事情:

> as.POSIXct("2008-03-30 02:00:00",format="%Y-%m-%d %H:%M:%S")
[1] NA
Run Code Online (Sandbox Code Playgroud)

但:

> as.POSIXct("2008-02-28 02:00:00",format="%Y-%m-%d %H:%M:%S")
[1] "2008-02-28 02:00:00 CET"
Run Code Online (Sandbox Code Playgroud)

我很无能为力.这是R中的一个错误吗?它可能与我的德国(柏林)地区有关吗?我正在使用R 2.14.2 for windows.

Ben*_*min 5

这是2008年德国夏令时的开始,请看这个链接.那段时间实际上相当于"2008-03-30 03:00:00"(一小时后),这应该适用于您的系统.所以,是的,这与您的语言环境有关.

  • 现在您已经知道问题所在,您可以在SO上搜索"[r]'夏令时'"并发现类似的混淆:http://stackoverflow.com/questions/9455096/xtss-hourly-endpoints-和日光节约,http://stackoverflow.com/questions/8408738/unexpected-behavior-of-scale-x-datetime-in-ggplot2,可能在R帮助列表上还有更多...... (3认同)