[R] Excel date to R format
Ben Bolker
bolker at ufl.edu
Tue Apr 13 01:52:30 CEST 2010
Gabor Grothendieck <ggrothendieck <at> gmail.com> writes:
>
> See the relevant article in R News 4/1.
>
> On Mon, Apr 12, 2010 at 10:36 AM, ManInMoon wrote:
> >
> > I have a vector of double like this from Excel.
> >
> > 39965.0004549653
> >
> > and I want to put them in R such that I can display them in any Date and
> > Time format.
> >
Emphasis:
> > as.Date does it ALMOST but chops off the fractional seconds.
> > POSIXct doesn't
> > appear to do what I need.
(ManInMoon: why not? A reproducible example would help.)
Gabor,
I looked at that R News article but can't figure out whether *any*
of these classes preserve sub-second resolution (which seems crazy to me;
I guess in the case of POSIXt there may be an ANSI standard that specifies
that 'seconds' are stored as integers, but otherwise this seems like
a needless restriction). Am I missing something?
Ben
> as.numeric(as.POSIXct(39965.004,origin=as.Date("1970-1-1")))
[1] 39965.00
More information about the R-help
mailing list