Hello, today I've updated on the newest R-Version. But sadly a function I needed didnt want to work: The input is e.g. days(as.Date("21-07-2005","%d-%m-%y")) the error is: Fehler in Math.Date(dts): floor nicht definiert f??r Date Objekte (Error in Math.Date(dts): floor not defined for date objects) Same for year. Only months gives me the correct output. In Version 2.01 it worked very well, with the same chron library. Whats wrong ? Carsten
I think its likely that you are using different versions of chron. I noticed that version "2.2-33" of chron had the statement: tms <- dts - trunc(dts) but version "2.2-35" seems to have replaced it with: tms <- dts - floor(dts) and that seems to be causing the problem. As a workaround: floor.Date <- floor.trunc days(as.Date("21-07-2005", "%d-%m-%y")) On 7/19/05, Carsten Steinhoff <carsten.steinhoff at stud.uni-goettingen.de> wrote:> Hello, > > today I've updated on the newest R-Version. But sadly a function I needed > didnt want to work: > The input is e.g. > > days(as.Date("21-07-2005","%d-%m-%y")) > > the error is: Fehler in Math.Date(dts): floor nicht definiert f??r Date > Objekte > (Error in Math.Date(dts): floor not defined for date objects) > > Same for year. Only months gives me the correct output. > In Version 2.01 it worked very well, with the same chron library. > Whats wrong ? > > Carsten > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
x <- as.Date("21-07-2005","%d-%m-%y") is base R, and gives you a object of class "Date". days() is not part of R, and I guess from your subject is part of chron. Its help page does not say what it actually does, but my guess is that it finds days of the month, *for a "dates" object not a "Date" object*. Try as.POSIXlt(x)$mday to get that. On Tue, 19 Jul 2005, Carsten Steinhoff wrote:> today I've updated on the newest R-Version. But sadly a function I needed > didnt want to work:It should never have worked, as you were using contrary to its documentation.> The input is e.g. > > days(as.Date("21-07-2005","%d-%m-%y")) > > the error is: Fehler in Math.Date(dts): floor nicht definiert f?r Date > Objekte > (Error in Math.Date(dts): floor not defined for date objects) > > Same for year. Only months gives me the correct output. > In Version 2.01 it worked very well, with the same chron library. > Whats wrong ?There is no version 2.01 of R: do see the posting guide! -- Brian D. Ripley, ripley at 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