[R] Time series documentation?

Spencer Graves spencer.graves at pdf.com
Sun Feb 20 05:45:08 CET 2005


Hi, Gabor: 

      Thanks.  Which package(s) do you prefer for which purposes? 

      Best Wishes,
      Spencer Graves

Gabor Grothendieck wrote:

>Spencer Graves <spencer.graves <at> pdf.com> writes:
>
>: 	  In particular, what's the preferred way to keep track of dates with 
>: time series?  I tried assigning a "Date" object somehow to a "ts" 
>: object, so far without success.  Two of my attempts are as follows:
>: 
>:  > tst2 <- ts(1:11, frequency=365,
>: +        start=c(2005, 11))
>: # This seemed to work, but the time does not seem to have class "Date"
>: 
>:  > tst3 <- ts(1:11, frequency=365,
>: +        start=as.Date("21/01/2005", "%d/%m/%Y"))
>: Error in Math.difftime((end - start) * frequency + 1.01) :
>: 	floor not defined for difftime objects
>: 
>: 	  Any suggestions would be greatly appreciated.  I'd gladly rtfm 
>("read 
>: the f****** manual"), but I don't know which fm to r.
>: 
>
>
>A 'ts' class series does not store a sequence of times but rather stores 
>a tsp attribute consisting of three numbers (see ?tsp).  The closest
>you can get to daily data with 'ts' is to use the internal 
>numeric representation of the Date like this:
>
># daily ts series 1:10 starting at Jan 22, 2000
>st <- as.Date("2000-01-22")
>my.ts <- ts(1:10, start = unclass(st))
>
># and then to get back the Date class dates
>structure(as.vector(time(my.ts)), class = "Date")
>
>This won't allow give you automatic date handling on plots etc.
>since it does not actually know that the numbers represent
>Date class dates.  (Note that if you want monthly data then
>ts has its own home represenation of dates and will automatically
>assume monthly data if you use the frequency = 12 argument
>to ts.)
>
>The zoo library can represent time series using the Date class
>(or nearly any other date class).  Here is an example of using
>zoo with daily Date class data:
>
>my.zoo <- zoo(1:10, as.Date("2000-01-22") + 0:9)
>time(my.zoo)
>
>The other time series packages (its, fBasics, tseries) use POSIXct 
>underneath.
>
>For more info about zoo:
>
>library(zoo)
>vignette("zoo")
>
>______________________________________________
>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
>  
>




More information about the R-help mailing list