tsdf: Time series to data frame

Description Usage Arguments Details Value Examples

View source: R/tsdf.R

Description

Convert a ts object to data.frame with columns for time period and the original data

Usage

1
tsdf(timeseries, colname = "x")

Arguments

timeseries

an object of class ts or mts

colname

Column name to give to the time period column

Details

A convenience function to create a data frame from a time series or multiple time series object. The motivation is to make it easy to pass time series data to functions that need data frames such as ggplot2.

Value

a data.frame with the same number of rows as the original time series

Examples

1
2
3
4

Example output

Loading required package: seasonal
The binaries provided by 'x13binary' do not work on this
machine. To get more information, run:
  x13binary::checkX13binary()

You can set 'X13_PATH' manually if you intend to use your own
binaries. See ?seasonal for details.

Loading required package: ggplot2
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

         x   y
1 1949.000 112
2 1949.083 118
3 1949.167 132
4 1949.250 129
5 1949.333 121
6 1949.417 135
         x fdeaths mdeaths
1 1974.000     901    2134
2 1974.083     689    1863
3 1974.167     827    1877
4 1974.250     677    1877
5 1974.333     522    1492
6 1974.417     406    1249

ggseas documentation built on June 12, 2018, 5:04 p.m.