Learn R Programming

aion (version 1.4.0)

series: Create Time Series

Description

Create Time Series

Usage

series(object, time, calendar, ...)

# S4 method for array,RataDie,missing series(object, time, names = NULL)

# S4 method for array,numeric,TimeScale series(object, time, calendar, scale = 1, names = NULL)

# S4 method for matrix,numeric,TimeScale series(object, time, calendar, scale = 1, names = NULL)

# S4 method for matrix,RataDie,missing series(object, time, names = NULL)

# S4 method for numeric,numeric,TimeScale series(object, time, calendar, scale = 1, names = NULL)

# S4 method for numeric,RataDie,missing series(object, time, names = NULL)

# S4 method for data.frame,numeric,TimeScale series(object, time, calendar, scale = 1, names = NULL)

# S4 method for data.frame,RataDie,missing series(object, time, names = NULL)

Value

A TimeSeries object.

Arguments

object

A numeric vector, matrix or array of the observed time-series values. A data.frame will be coerced to a numeric matrix via data.matrix().

time

A numeric vector of (decimal) years or a RataDie object (see fixed()).

calendar

A TimeScale object specifying the calendar of time (see calendar()). If missing, time must be a RataDie object.

...

Currently not used.

names

A character string specifying the names of the time series.

scale

A length-one numeric vector specifying the number of years represented by one unit. It should be a power of 10 (i.e. 1000 means ka).

Author

N. Frerebeau

Details

Data will be sorted in chronological order.

Examples

Run this code
## Create time-series of 20 observations

## Univariate
## Sampled every years starting from 1029 BCE
(X <- series(rnorm(30), time = 1029:1000, calendar = BCE()))

## Terminal and sampling times (returns rata die)
start(X)
end(X)
time(X)
span(X)

## Multivariate
## Sampled every century starting from 1000 CE
(Y <- series(matrix(rnorm(90), 30, 3), time = 1000:1029, calendar = CE()))

## Terminal and sampling times (returns Gregorian Common Era years)
start(Y, calendar = CE())
end(Y, calendar = CE())
time(Y, calendar = CE())
span(Y, calendar = CE())

## Coerce to data frame
df <- as.data.frame(Y, calendar = BP())
head(df)

Run the code above in your browser using DataLab