当我尝试阅读vector a
包含许多日期的内容时,我收到了警告。
这是vector a
我使用write(a,"a.txt")
. 由于它相当大,我已将其附在 Google 驱动器上供任何人下载。基本上,它包含从 2012-01-01 到 2012-12-31 的日期,重复了很多次。
https://drive.google.com/file/d/0B12dCpdCVHeSZjA4YmVXNmV6VUU/edit?usp=sharing
我试图这样做并收到一条警告消息。
> head(ymd(a))
[1] "2012-01-01 UTC" "2012-01-01 UTC" "2012-01-01 UTC" "2012-01-01 UTC" "2012-01-01 UTC"
[6] "2012-01-01 UTC"
Warning message:
7202 failed to parse.
查看警告消息,很容易假设日期格式错误。但是,YYYY-MM-DD 是 lubridate 支持的格式。当我对向量的一部分做同样的事情时,什么也没有发生。
> head(ymd(a[1:50000]))
[1] "2012-01-01 UTC" "2012-01-01 UTC" "2012-01-01 UTC" "2012-01-01 UTC" "2012-01-01 UTC"
[6] "2012-01-01 UTC"
使用strptime
andas.Date
也不会产生任何错误
> head(strptime(a,format="%Y-%m-%d"))
[1] "2012-01-01" "2012-01-01" "2012-01-01" "2012-01-01" "2012-01-01" "2012-01-01"
> head(as.Date(a))
[1] "2012-01-01" "2012-01-01" "2012-01-01" "2012-01-01" "2012-01-01" "2012-01-01"
我的问题是,我需要担心警告消息还是可以安全地忽略它?