timeSeries Class

Functions to generate and modify 'timeSeries' objects:

ll{ timeSeries Creates a 'timeSeries' object from scratch.} Data Slot and classification of 'timeSeries' objects: ll{ seriesData Extracts data slot from a 'timeSeries'. }

timeSeries(data, charvec, units = NULL, format = NULL, zone = "", 
    FinCenter = "", recordIDs = data.frame(), title = NULL, 
    documentation = NULL, ...)


a character vector of dates and times or any objects which can be coerced to a timeDate object.
a matrix object or any objects which can be coereced to a matrix.
optional documentation string, or a vector of character strings.
a character with the the location of the financial center named as "continent/city".
the format specification of the input character vector, [as.timeSeries] - a character string with the format in POSIX notation to be passed to the time series object.
[is][seriesData][seriesPositions][show][summary] - an object of class timeSeries.
a data frame which can be used for record identification information. [print] - a logical value. Should the recordIDs printed together with the data matrix and time series positions?
an optional title string, if not specified the inputs data name is deparsed.
an optional character string, which allows to overwrite the current column names of a timeSeries object. By default NULL which means that the column names are selected automatically.
the time zone or financial center where the data were recorded.
arguments passed to other methods.

Generation of Time Series Objects: We have defined a timeSeries class which is in many aspects similar to the S-Plus class with the same name, but has also some important differences. The class has seven Slots, the 'Data' slot which holds the time series data in matrix form, the 'position' slot which holds the time/date as a character vector, the 'format' and 'FinCenter' slots which are the same as for the 'timeDate' object, the 'units' slot which holds the column names of the data matrix, and a 'title' and a 'documentation' slot which hold descriptive character strings. Date and time is managed in the same way as for timeDate objects.


  • timeSeries returns a S4 object of class timeSeries. seriesData extracts the @.Data slot from a timeSeries object and is equivalent to as.amtrix.


These functions were written for Rmetrics users using R and Rmetrics under Microsoft's Windows operating system where timze zones, daylight saving times and holiday calendars are insuffeciently supported.

  • TimeSeriesClass
  • timeSeries
  • timeSeries,ANY,ANY-method
  • timeSeries,ANY,missing-method
  • timeSeries,ANY,timeDate-method
  • timeSeries,matrix,ANY-method
  • timeSeries,matrix,missing-method
  • timeSeries,matrix,timeDate-method
  • timeSeries,missing,ANY-method
  • timeSeries,missing,missing-method
  • timeSeries,missing,timeDate-method
  • timeSeries,matrix,numeric-method
  • index_timeSeries
  • time_timeSeries
  • timeSeries-class
  • index_timeSeries-class
  • time_timeSeries-class
  • initialize,timeSeries-method
  • seriesData
library(timeSeries) ## Load Microsoft Data - # Microsoft Data: setRmetricsOptions(myFinCenter = "GMT") data(MSFT) head(MSFT) ## Create a timeSeries Object, The Direct Way ... Close <- MSFT[, 5] head(Close) ## Create a timeSeries Object from Scratch - data <- as.matrix(MSFT[, 4]) charvec <- rownames(MSFT) Close <- timeSeries(data, charvec, units = "Close") head(Close) c(start(Close), end(Close)) ## Cut out April Data from 2001 - tsApril01 <- window(Close, "2001-04-01", "2001-04-30") tsApril01 ## Compute Continuous Returns - returns(tsApril01) ## Compute Discrete Returns - returns(tsApril01, type = "discrete") ## Compute Discrete Returns, Don't trim - returns(tsApril01, trim = FALSE) ## Compute Discrete Returns, Use Percentage Values - tsRet <- returns(tsApril01, percentage = TRUE, trim = FALSE) tsRet ## Aggregate Weekly - GoodFriday(2001) to <- timeSequence(from = "2001-04-11", length.out = 3, by = "week") from <- to - 6*24*3600 from to applySeries(tsRet, from, to, FUN = sum) ## Create large timeSeries objects with different 'charvec' object classes - # charvec is a 'timeDate' object head(timeSeries(1:1e6L, timeSequence(length.out = 1e6L, by = "sec"))) head(timeSeries(1:1e6L, seq(Sys.timeDate(), length.out = 1e6L, by = "sec"))) # 'charvec' is a 'POSIXt' object head(timeSeries(1:1e6L, seq(Sys.time(), length.out = 1e6L, by = "sec"))) # 'charvec' is a 'numeric' object head(timeSeries(1:1e6L, 1:1e6L))
Documentation reproduced from package timeSeries, version 3022.101.2, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.