[R] Parenthesis around date/time using chron?

Gabor Grothendieck ggrothendieck at gmail.com
Fri Apr 24 00:27:56 CEST 2009


Try this:

> x <- as.chron(Sys.time())
> format(x, enclosed = c("", ""))
[1] "04/23/09 22:26:23"


On Thu, Apr 23, 2009 at 6:03 PM, Kenneth Takagi <kat215 at psu.edu> wrote:
> Hi,
>
>
>
> I've been using the chron package to convert excel time into
> month/day/year and h:m:s formats, specifically for use as axis labels.
> I've come across something I don't quite understand.
>
>
>
> ### Here are some excel times:
>
> dat = c(39083, 39083.00694, 39083.01389, 39083.02083, 39083.02778,
>
> 39083.03472, 39083.04167, 39083.04861, 39083.05556, 39083.0625
>
> )
>
>
>
> ### I create date/time vectors from excel times:
>
> orig =chron("01/01/1900");
>
> # month/day/year h:m:s format
>
> date.time = orig + dat-2;
>
> # h:m:s format
>
> time= date.time - floor(date.time);
>
> # month/day/year format
>
> date = orig + floor(dat)-2;
>
>
>
> #I can easily recreate the date.time vector without the parenthesis (as
> characters though):
>
> paste(date, time)
>
>
>
> But, I don't see why the values in the ORIGINAL date.time vector have
> parenthesis around them?  Is there as specific reason?
>
>
>
> Thanks!
>
>
>
> ken
>
>
>
> kat215 at psu.edu
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
>




More information about the R-help mailing list