Defines functions offsetdate

Documented in offsetdate

offsetdate <- function(ltraj, offset, units=c("sec", "min", "hour", "day"))
    if (!inherits(ltraj,"ltraj"))
        stop("ltraj should be of class \"ltraj\"")
    if (!attr(ltraj,"typeII"))
        stop("ltraj should be of type II (time recorded)")

    units <- match.arg(units)
    offset <- .convtime(offset, units)

    res <- lapply(ltraj, function(x) {
        date <- as.numeric(x$date)
        date <- date - offset
        class(date) <- c("POSIXct","POSIXt")
        x$date <- date
    class(res) <- c("ltraj", "list")
    attr(res,"typeII") <- TRUE
    attr(res,"regular") <- is.regular(res)

Try the adehabitat package in your browser

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

adehabitat documentation built on Jan. 28, 2018, 5:02 p.m.