R/tis.R

Defines functions tbind.tis tfwindow.tis Tobs.tistframe tfend.tistframe tfstart.tistframe Tobs.tis tfend.tis tfstart.tis tfSet.tistframe is.tframed.tis

Documented in tfend.tis tfend.tistframe tfSet.tistframe tfstart.tis tfstart.tistframe tfwindow.tis Tobs.tis Tobs.tistframe

is.tframed.tis <- function(x) {TRUE}

tframe.tis <- function (x) {
  tf <- time(x)
  attr(tf, "start") <- attr(x, "start")
  class(tf) <- c( "tistframe", class(tf), "tframe")
  tf
  }

tfSet.tistframe <- function(value, x) {
   r <- tis::tis(x, start=attr(value, "start") )
   if (inherits(r, "try-error")) {r <- x ; attr(r, "tframe") <- value}
   r
   }

tfstart.tis <- function(x) start(x)  #tis::start(x)
tfend.tis   <- function(x) end(x)    #tis::end(x)

Tobs.tis <- function(x)  NROW(x)

tfstart.tistframe <- function(x) x[1]
tfend.tistframe   <- function(x) x[length(x)]
Tobs.tistframe     <- function(x) length(x)

tfwindow.tis <- function(x, tf=NULL, start=tfstart(tf), end=tfend(tf), warn=TRUE)
  {# With the default warn=T warnings will be issued if no truncation takes
   #  place because start or end is outside the range of data.
   y <- window(x, start=start, end=end, noWarn=!warn)
   seriesNames(y) <- seriesNames(x)
   y
  }

tbind.tis <- function(x, ..., pad.start=TRUE, pad.end=TRUE, warn=TRUE)
 {nm <- seriesNames(x)
  for (z in list(...)) {
    if (!is.null(z)) {
      nm <- c(nm, seriesNames(z))
      x <- cbind(x, z)
      }
    }
  if (!pad.start | !pad.end)
     x <- trimNA(x, startNAs= !pad.start, endNAs= !pad.end)
  seriesNames(x) <- nm
  x
 }  

Try the tframePlus package in your browser

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

tframePlus documentation built on March 18, 2022, 7:35 p.m.