Re: [R] integers to POSIXct

From: Prof Brian Ripley <>
Date: Mon 09 Oct 2006 - 15:56:16 GMT

On Wed, 4 Oct 2006, paul sorenson wrote:

> What is the recommended way to convert/coerce and integer to a POSIXct
> please?
> d <- as.POSIXct(Sys.Date())
> i <- as.integer(d)
> as.POSIXct(i)
> Error in as.POSIXct.default(i) : do not know how to convert 'i' to class
> "POSIXlt"
> This appears to be the behaviour in 2.3.1 and 2.4.0 on windows XP.
> I have tried searching on this and found as.Date.integer in package zoo
> which performs a similar function but wondered if there was something
> basic I was missing in the base distribution?

It's documented on the help page for as.POSIXct in 2.4.0. What that integer means is undefined unless you also tell R the time origin.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Oct 10 01:59:35 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 09 Oct 2006 - 16:30:09 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.