but even this is dubious, since there is no year 0 AD. In Gregorian
and Julian calendars, 1 BC continues directly into 1 AD.
True, but these days we are ruled by ISO 8601:2004, which does define
a year 0 (the year before 1CE aka 1AD). See
http://en.wikipedia.org/wiki/0_(year) .
It seems also to redefine the meaning of 'Gregorian calendar' calling
what you are referring to the 'BC/AD calendar system'. (Those who
prefer BCE/CE to BC/AD might note the usage of the latter in the
definitive international standard.)
On Mon, 18 Jul 2011, peter dalgaard wrote:
On Jul 18, 2011, at 14:08 , Gabor Grothendieck wrote:
On Sat, Jul 16, 2011 at 11:50 PM, Eduardo M. A. M. Mendes
<emammen...@gmail.com> wrote:
Hello
I am new to R and I need to convert some dates (numeric format by matlab) to
actual dates in R.
For instance,
Matlab -> 730456 -> >> datestr(730456)
ans =
02-Dec-1999
Set the origin to Matlab's origin like this. Be sure you are using
the indicated version of zoo or later:
library(zoo)
packageVersion("zoo")
[1] ‘1.7.1’
as.Date(730456, origin = "0000-00-00")
[1] "1999-12-02"
Doesn't work on a Mac, and in general, I think it depends on a quirk in your
OS's date conversion utilities. What does work for me is
as.Date(730456-1, origin='0000-01-01')
[1] "1999-12-02"
but even this is dubious, since there is no year 0 AD. In Gregorian
and Julian calendars, 1 BC continues directly into 1 AD.
So, to be sure, try
as.Date(730456-367, origin='0001-01-01')
[1] "1999-12-02"
(from which it transpires that the non-existing year 0 is a leap year...).
Or, or course, just use the appropriate "magic constant" of 719529 and begone
with it:
as.Date(730456-719529)
[1] "1999-12-02"
I fail to see what "zoo" has to do with this at all!
--
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd....@cbs.dk Priv: pda...@gmail.com
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
--
Brian D. Ripley, rip...@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.