[R] timeDate & business day

Gabor Grothendieck ggrothendieck at gmail.com
Tue Mar 13 07:07:29 CET 2007


Regarding time series manipulation in R you could read the
two vignettes that come with the zoo package:

library(zoo)
vignette("zoo")
vignette("zoo-quickref")

Note that zoo is an entirely different system than rmetrics and timeDate so
if your question is specifically aimed at timeDate this does not answer it.
Regarding dates see R News 4/1 help desk article. This article discusses
Date, chron and POSIXct classes, any of which can be used with zoo.


On 3/13/07, Young Cho <young.stat at gmail.com> wrote:
> Thanks so Michael! If you know of a tutorial or introductory document
> about timeDate manipulation or time series manipulation in R, can you
> share it? It is hard to find by googling... I'd very appreciate any
> advice.
>
> Young.
>
> On Mar 12, 2007, at 9:00 PM, Michael Toews wrote:
>
> >
> >> [1] 20050104 20050105 20050106 20050107 20050110 20050111 20050113
> >> 20050114
> >>> ymd <- as.Date(as.character(ymd.int),"%Y%m%d")
> >>> ymd
> >> [1] "2005-01-04" "2005-01-05" "2005-01-06" "2005-01-07" "2005-01-10"
> >> [6] "2005-01-11" "2005-01-13" "2005-01-14"
> >>> class(ymd)
> >> [1] "Date"
> >>
> >> While the variable ymd is actually of class Date, the format is
> >> not yyyymmdd but
> >> yyyy-mm-dd as one can see in the previous example.
> >> As Young, I do not see what I am missing here.
> >> Any hint would be appreciated.
> >>
> >> AA.
> > What happened in the beginning is that I had to parse the character
> > into a Date-Time class ("Date", in this case as you correctly
> > pointed out). POSIX is a kind of standard that (mainly Unix)
> > computers use date formatters, such as %Y for a 4-digit year, and
> > others. They are all listed in great detail in "?strptime" (which
> > means "string parse time"). In this case the input parsing format
> > pattern was "%Y%m%d". There were no spaces in-between each number.
> >
> > When that class prints out, the default format is ISO 8601 ( see
> > http://en.wikipedia.org/wiki/ISO_8601 ). When R prints the class
> > "Date" to your screen, it decides to format it ISO 8601-style for
> > you. If you want to see if differently, you can try:
> >
> > format(ymd,"%Y/%d/%m")
> >
> > The date is actually stored internally as an ordinal, somewhat like
> > how MS Excel dates work. You can see how it works internally:
> >
> > str(ymd)
> >
> > Hopefully I've demystified some of this .. any other questions?
> > +mt
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list