0

Does anyone have a clue why in the following code I get "Time difference of NA secs" result? I was expecting to get the difference of days, like the It did for "2015-01-06".

today <- Sys.Date()
today <- strptime(today, "%Y-%m-%d")
date <- "2015-01-06"
date <- strptime(date, "%Y-%m-%d")
today - date
Time difference of 321 days

Well done. But then...

date <- "2015-10-18"
date <- strptime(date, "%Y-%m-%d")
today - date
Time difference of NA secs

Why secs?

EDIT: Here is session info

R version 3.2.1 (2015-06-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252   
[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C                      
[5] LC_TIME=Portuguese_Brazil.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.2.1

0 Answers0