Skip to content
Prev 2584 / 15274 Next

Solicitation of opinions on which Timeseries object(s) to utilize.

On Wed, Jan 23, 2008 at 12:10 AM, Joe W. Byers <ecjbosu at aim.com> wrote:
Actually this only is about the time index and that may be unrelated to the
time series package.  For example, zoo uses just about any time index
as long as the class supports certain methods so whether or not a particular
time index class is any good may be an orthogonal question.  Its only for
time series classes that have hard coded which time indexes can be used
with them that that might be a consideration.

e.g.

library(zoo)

dts <- c("1989-09-28", "2001-01-15", "2004-08-30", "1990-02-09")

# zoo object with "timeDate" class index
library(fSeries)
zoo(11:14, timeDate(dts))

# zoo object with "Date" class index
zoo(11:14, as.Date(dts))

# zoo object with "POSIXct" class index
zoo(11:14, as.POSIXct(dts))

# zoo object with chron "dates" class index
library(chron)
zoo(11:14, chron(dts, format = "y-m-d"))

# zoo object with "numeric" index
# using number of days since Epoch
zoo(11:14, as.numeric(as.Date(dts)))

# zoo object with "character" class as index
zoo(11:14, dts)