R/head.ts.r

Defines functions tail.ts head.ts

Documented in head.ts tail.ts

head.ts <- function(x, n = 5, ...) {
  if (n > dim(as.matrix(x))[1]) {
    return(x)
  } else {
    return(window(x, start = start(x), end = start(x) + c(0, n - 1), 
      frequency=tsp(x)[3]))
  }
}

tail.ts <- function(x, n = 5, ...) {
  if (n > dim(as.matrix(x))[1]) {
    return(x)
  } else {
    return(window(x, start = end(x) - c(0, n - 1), end = end(x), 
      frequency = tsp(x)[3]))
  }
}

Try the erer package in your browser

Any scripts or data that you put into this service are public.

erer documentation built on April 18, 2022, 5:06 p.m.