as.data.frame: Coerce to a Data Frame

as.data.frameR Documentation

Coerce to a Data Frame

Description

Coerce to a Data Frame

Usage

## S4 method for signature 'TimeSeries'
as.data.frame(x, ..., calendar = NULL)

## S4 method for signature 'TimeIntervals'
as.data.frame(x, ..., calendar = NULL)

Arguments

x

A TimeSeries or a TimeIntervals object.

...

Further parameters to be passed to data.frame().

calendar

A TimeScale object specifying the target calendar (see calendar()). If NULL (the default), rata die are returned.

Value

A data.frame.

Methods (by class)

  • as.data.frame(TimeSeries): Returns a long data.frame with the following columns:

    time

    The sampling times. If calendar is not NULL, it is expressed in decimal years; otherwise, it is expressed in rata die.

    series

    The name of the time series.

    variable

    The name of the variables.

    value

    The observed value.

  • as.data.frame(TimeIntervals): Returns a data.frame with the following columns:

    label

    The name of the intervals.

    start

    The start time of the intervals. If calendar is not NULL, it is expressed in decimal years; otherwise, it is expressed in rata die.

    end

    The end time of the intervals. If calendar is not NULL, it is expressed in decimal years; otherwise, it is expressed in rata die.

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.