Learn R Programming

onlineforecast (version 1.0.0)

as.data.list: Convert to data.list class

Description

These functions will convert the object into a data.list.

Convert a data.frame into a data.list

Usage

as.data.list(object)

# S3 method for data.frame as.data.list(object)

Arguments

object

The data.frame to be converted.

Value

a value of class data.list

a data.list

Details

A data.list is simply a list of vectors and data.frames. For the use in the onlineforecast package the following format must be kept:

- t: A vector of time.

- vectors with same length as t: Holds observations and values synced to time t.

- data.frames with number of rows as time t: Holds forecasts in each column named by kxx where xx is the horizon, e.g. k0 is synced as observations, and k1 is one-step ahead.

The convention is that columns with forecasts are postfixed with .kxx where xx is the horizon. See the examples.

See Also

For specific detailed info see the children, e.g. as.data.list.data.frame

as.data.list

Examples

Run this code
# NOT RUN {
# Convert a dataframe with time and two observed variables
X <- data.frame(t=1:10, x=1:10, y=1:10)
as.data.list(X)

# Convert a dataframe with time, forecast and an observed variable
X <- data.frame(t=1:10, x.k1=1:10, x.k2=10:1, yobs=1:10, y.k1=1:10, y.k2=1:10)
as.data.list(X)

# Can be converted back and forth
X
as.data.frame(as.data.list(X))

# }

Run the code above in your browser using DataLab