Learn R Programming

erer (version 4.0)

headts: Return the first or last part of time series data

Description

Return the first of last parts of an object of time series data.

Usage

headts(x, n = 5, ...)
  tailts(x, n = 5, ...)

Value

An object like x but generally smaller.

Arguments

x

input time seires data.

n

a single integer for the length or row of returned data

...

additional arguments to be passed.

Author

Changyou Sun (edwinsun258@gmail.com)

Details

The data can be an univariate or multivariate time series data.

Examples

Run this code
h1 <- ts(data=cbind(1:24), start=c(2001, 1), frequency=12)
h2 <- ts(data=cbind(1:24, 25:48), start=c(2001, 1), frequency=12)
h3 <- ts(data=cbind(1:4, 5:8, 9:12), start=c(2001, 1), frequency=4)
colnames(h2) <- c("aa", "bb")
colnames(h3) <- c("cc", "dd", "ee")
h1; h2; h3

h1; headts(h1); tailts(h1, 28)
h2; headts(h2); tailts(h2, 50)
h3; headts(h3, 2); tailts(h3); tailts(h3, 8)

data(daBed); headts(daBed); tailts(daBed)

Run the code above in your browser using DataLab