Learn R Programming

iNZightTS (version 1.5.7)

iNZightTS: iNZightTS (Time-Series) Objects

Description

The function iNZightTS is used to create time-series objects used in iNZight.

Usage

iNZightTS(
  data,
  start = 1,
  end,
  freq = 1,
  var = 2,
  time.col = grep("time", names(data), ignore.case = TRUE)[1],
  ...
)

Arguments

data

a data.frame containing time information and observation or a path to a .csv file with such information or a ts object

start

the time of the first observation. Either a single number or a vector of two integers, which specify a natural time unit and a (1-based) number of samples into the time unit

end

the time of the last observation, specified in the same way as start

freq

the number of observations per unit of time

var

the column number or name for the observations used from data in the actual time series

time.col

which column contains the time variable

...

additional information passed to read.csv() and used when data is a path

ignore.case

logical, ignore the case?

Value

a iNZightTS object. If multiple variables are requested, the iNZightMTS class is added to the result. The result object contains the original data as a time series object, as well as information on the series start, end, and frequency.

Details

The function iNZgithTS is used to create time-series objects. Unlike ts objects, these are lists containing information about the time-series as well as the data and the time-series (ts object) itself.

If a ts object is used to create the iNZightTS object, all the domain information is extracted from that object.

The function recognises the following time variable formatS without case sensitive:

  • "(Y)yyyy" annually data e.g."(Y)1991"

  • "(Y)yyyyMmm" monthly data e.g."(Y)1991M01"

  • "(Y)yyyyQqq" quarterly data e.g."(Y)1991Q01"

  • "(Y)yyyyWww" weekly data with yearly seasonality e.g."(Y)1991W01"

  • "(Y)yyyyDdd" daily data with yearly seasonality e.g."(Y)1991D01"

  • "WwwDdd" daily data with weekly seasonality e.g. "W01D01"

  • "DddHhh" hourly data with daily seasonality e.g. "D01H01"

The length of digits of each time unit could be flexible and allowing space between the time unit

In case of data being a data.frame or path to a .csv file and start being omitted, the starting date and the freq is extracted from the column that includes the time information. This column is either named "Time" or is the first column. If end is omitted, all of the data will be used for the time-series.

See Also

ts, print.iNZightTS,

Examples

Run this code
# NOT RUN {
# create from a ts object
z <- iNZightTS(UKgas)
plot(z)

# create from a data.frame
x <- iNZightTS(data.frame(Return = rnorm(100), Time = 1900:1999),
    var = "Return")
# or specify a time column
x <- iNZightTS(data.frame(Return = rnorm(100), Year = 1900:1999),
    var = "Return", time.col = "Year")

# create from a data.frame with modified time frame
y <- iNZightTS(data.frame(Return = rnorm(100)),
    start = c(1990, 1), end = c(1993, 5), freq = 12, var = 1)
plot(y)

# }

Run the code above in your browser using DataLab