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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 20 Jul 2005 - 18:25:09 EST

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@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@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

Received on Wed Jul 20 18:30:08 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:51 EST