0
我想一个字符串转换为POSIXct对象,但如果我这样做as.POSXct返回NA
x <- as.POSIXct('15/10/17', tz = 'America/Sao_Paulo', format = '%d/%m/%y')
输出为NA。我认为这是因为它在15/10/17日在圣保罗成为夏令时,因此当天的午夜不存在。一个解决办法是迫使X是在那天的另一个值像
x <- structure(1508036400, class = c("POSIXct", "POSIXt"), tzone = "America/Sao_Paulo")
但我wodering如果有一个更优雅的解决方案。
我的会话信息:
> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 LC_MONETARY=Portuguese_Brazil.1252
[4] LC_NUMERIC=C LC_TIME=Portuguese_Brazil.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.2 tools_3.4.2 yaml_2.1.14 fortunes_1.5-4
提前感谢!