Re: [R] Preserving dates in Excel.

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu, 14 Jun 2007 13:47:10 +0100 (BST)

On Thu, 14 Jun 2007, Patnaik, Tirthankar wrote:

> Hi,
> Quick question: Say I have a date variable in a data frame or
> matrix,

Which? It matters: see the help page.

> and I'd like to preserve the date format when using write.table.
> However, when I export the data, I get the generic number underlying the
> date, not the date per se, and a number such as 11323, 11324, etc are
> not meaningful in Excel. Is there any way I can preserve the format of a
> date on writing into a text-file?

Yes, see the help page and use a data frame. E.g.

> write.table(data.frame(x=.leap.seconds[1:3]), "")

"x"
"1" 1972-07-01 01:00:00
"2" 1973-01-01 00:00:00
"3" 1974-01-01 00:00:00


-- 
Brian D. Ripley,                  ripley_at_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_at_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 14 Jun 2007 - 12:54:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 14 Jun 2007 - 13:31:57 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.