问题描述
当我转换一个无害的字符串时,我偶然发现as.Date
函数的一个令人惊讶的行为:
d0 <- "05-06-20" # my innocent date string for the fifth of June 2020
d1 <- as.POSIXct(d0,format="%d-%m-%y") # Converted to "2020-06-05 CEST",containing time zone
d2 <- as.Date(d1) # "2020-06-04",it has moved one day back,when I just want the date
d3 <- anytime::anydate(d1) # "2020-06-05" gives the correct conversion
有人能解释为什么as.Date
弄错了吗?
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)