Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

head.ts

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

## S3 method for class 'ts'
head(x, n = 5, ...)
  ## S3 method for class 'ts'
tail(x, n = 5, ...)

Arguments

x

input time seires data.

n

a single integer for the length or row of returned data

...

additional arguments to be passed.

Details

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

Value

An object like x but generally smaller.

Author(s)

Changyou Sun (cs258@.msstate.edu)

Examples

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; head(h1); tail(h1, 28)
h2; head(h2); tail(h2, 50)
h3; head(h3, 2); tail(h3); tail(h3, 8)

data(daBed); head(daBed); tail(daBed)

erer

Empirical Research in Economics with R

v3.0
GPL (>= 2)
Authors
Changyou Sun <cs258@msstate.edu>
Initial release
2020-04-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.