[R] Problems with date-format (R 2.1.1 + chron)

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jul 20 10:25:09 CEST 2005


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


More information about the R-help mailing list