https://github.com/cran/simecol
Raw File
Tip revision: 6d46a26c937edfe976d8d5173867f6e1b246bb24 authored by Thomas Petzoldt on 15 July 2019, 20:20:05 UTC
version 0.8-13
Tip revision: 6d46a26
fromtoby.R
## the fromtoby-vector form is intended to give users
## a compact representation of time steps without the need to apply
## time series classes as "ts" or "zoo"
## "fromtoby" vectors are optional, ordinary sequences are possible too

## check for from-to-by structure of vector
isfromtoby <- function(x) {
  (sum(names(x) %in% c("from","to","by"))==3)
}

hasfromtoby <- function(x) {
  any(names(x) %in% c("from","to","by"))
}

## expand from-to-by-vector to sequence
fromtoby <- function(times) {
  if (isfromtoby(times)) {
    times <- seq(times["from"], times["to"], times["by"])
  } 
  times
}
back to top