r - date discrepancy in zoo package when setting origin -


when try as.date(42010, origin = "1900-01-01") or as.date.numeric(...) zoo package in r; returns jan 8 2015 instead of jan 6, while can change origin 2 days sort this, wonder why issue coming up.

like @akrun wonder why expect jan 6 outcome. checked base r , various online calendars there 42010 days between 2015-01-08 , 1900-01-01:

as.date("2015-01-08") - as.date("1900-01-01") ## time difference of 42010 days 

note has nothing zoo package. as.date.numeric function in zoo , base r differ in default value origin. while authors in r core team argue unreasonable give default, zoo package has chosen use same default as.numeric.date function (i.e., 1970-01-01). therefore, outcome same no matter whether base r's or zoo's as.date function used:

base::as.date(42010, origin = "1900-01-01") ## [1] "2015-01-08" zoo::as.date(42010, origin = "1900-01-01") ## [1] "2015-01-08" 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -