Hi everybody, I have a strange behavior of the as.Date() function. For example: as.Date(36525, origin="1900-01-01'") I would expect to get 2000-01-01. But R gives me [1] "2070-01-01" I tried with several origins but the results are still the same. It seems that the origin does not apply and remains 1970-01-01. Does anyone can give me a hint how to solve this problem? Thanks very much. Fabio ------------------------------------------------------------------------ --- Fabio Valeri, MSc University of Bern Institute of Social and Preventive Medicine Division of International & Environmental Health Finkenhubelweg 11 - CH-3012 Bern Tel +41 (0)31 631 35 10 - Fax +41 (0)31 631 35 20 - www.ispm.ch [[alternative HTML version deleted]]
On Feb 8, 2011, at 11:15 AM, Valeri Fabio wrote:> Hi everybody, > > > > I have a strange behavior of the as.Date() function.No, you have a programming error.> For example: > > > > as.Date(36525, origin="1900-01-01'")You have a superfluous "'" > as.Date(36525, origin="1900-01-01") [1] "2000-01-02"> > > > I would expect to get 2000-01-01. But R gives me > > > > [1] "2070-01-01" > > > > I tried with several origins but the results are still the same. It > seems that the origin does not apply and remains 1970-01-01. > > > > Does anyone can give me a hint how to solve this problem? > > > > Thanks very much. > > > > Fabio > > > > > > > > > > > > ------------------------------------------------------------------------ > --- > > Fabio Valeri, MSc > > University of Bern > > Institute of Social and Preventive Medicine > > Division of International & Environmental Health > > Finkenhubelweg 11 - CH-3012 Bern > > Tel +41 (0)31 631 35 10 - Fax +41 (0)31 631 35 20 - www.ispm.ch > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT
> I have a strange behavior of the as.Date() function. For example: > as.Date(36525, origin="1900-01-01'") > > I would expect to get 2000-01-01. But R gives meThat's almost exactly what I get with R 2.11.1, LINUX (minus the one-day differnce which is probably correct, too lazy to count leap years...):> as.Date(36525, origin="1900-01-01'")[1] "2000-01-02" At first I thought the excess single quote maight be causingyour problem, but it doesn't for me. Maybe you need to upgrade R? Possibly it's an already fixed issue? cu Philipp -- Dr. Philipp Pagel Lehrstuhl f?r Genomorientierte Bioinformatik Technische Universit?t M?nchen Wissenschaftszentrum Weihenstephan Maximus-von-Imhof-Forum 3 85354 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/