as.array: Coerce to an Array

as.arrayR Documentation

Coerce to an Array

Description

Coerce to an Array

Usage

## S4 method for signature 'TimeSeries'
as.array(x, ...)

Arguments

x

A TimeSeries.

...

Currently not used.

Value

An array.

Note

June 2026: aperm.default() now copy attributes, this change how apply() works on classed objects. The simplest "fix" is to add an aperm() S3 method for the class which drops attributes as aperm.default() previously did. Alternatively, one could also consider providing as.matrix()/as.array() methods which change to standard matrix/array.

Author(s)

N. Frerebeau

Examples

## 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)

aion documentation built on June 23, 2026, 5:06 p.m.