iNZightTS: iNZightTS (Time-Series) Objects

Description Usage Arguments Details Value See Also Examples

View source: R/iNZightTS.R

Description

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

Usage

1
2
3
4
5
6
7
8
9
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?

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:

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.

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.

See Also

ts, print.iNZightTS,

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 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)

iNZightTS documentation built on Feb. 1, 2022, 1:08 a.m.