Re: [R] integers to POSIXct

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed 04 Oct 2006 - 14:19:46 GMT

Here are a few ways:

now <- Sys.time()
Epoch <- now - as.numeric(now)
i + Epoch

structure(i, class = c("POSIXt", "POSIXct"))

class(i) <- c("POSIXt", "POSIXct")

On 10/4/06, paul sorenson <news01@metrak.com> 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?
>
> cheers
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



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 and provide commented, minimal, self-contained, reproducible code. Received on Thu Oct 05 00:24:30 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 Wed 04 Oct 2006 - 15:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.