[Rd] converting #sec to POSIX* format
ripley@stats.ox.ac.uk
ripley@stats.ox.ac.uk
Wed, 1 May 2002 18:32:31 +0100 (BST)
On 1 May 2002, Peter Dalgaard BSA wrote:
> lsjensen <lsjensen@micron.com> writes:
>
> > Sure I'm missing something simple here, but I haven't been able to find a
> > easy way to convert a pure numeric (# of seconds since the beginning of
> > 1970) back into a POSIX* object.
> >
> > ex.
> > > z<-as.POSIXct(Sys.time())
It's POSIXct already.
> > > z
> > [1] "2002-05-01 10:33:56 Mountain Daylight Time"
> > > x<-unclass(z)
> > > x
> > [1] 1020270836
> >
> > Is there a simple way to transform x back into a POSIX* object similar to z?
>
> > 1020270836 + ISOdate(1970,1,1,0,0)
> [1] "2002-05-01 18:33:56 CEST"
Or, as you did unclass(), reverse that by classing it:
class(x) <- c("POSIXt", "POSIXct")
--
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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._