R/runsNAltraj.r

"runsNAltraj" <- function (x, nrep = 500, plotit = TRUE, ...)
{
    if (!inherits(x,"ltraj"))
        stop("x should be of class 'ltraj'")
    opar <- par(mfrow=n2mfrow(length(x)))
    on.exit(par(opar))
    foo <- function(x) {
        x <- as.numeric(is.na(x[,1]))
        n <- length(x)
        if (sum(x)>2) {
            toto <- .C("runsltr", as.integer(x), as.integer(n), double(nrep+1),
                       as.integer(nrep), PACKAGE = "adehabitatLT")[[3]]
            li <- as.randtest(toto[2:length(toto)], toto[1], alter="less")
            return(li)
        } else {
            return(NULL)
        }
    }

    uu <- lapply(x, foo)
    names(uu) <- unlist(lapply(x, function(i) attr(i, "burst")))
    if (plotit) {
        lapply(1:length(uu), function(i) if (!is.null(uu[[i]]))
               plot(uu[[i]], main=names(uu)[i], ...))
    }
    invisible(uu)
}

Try the adehabitatLT package in your browser

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

adehabitatLT documentation built on April 6, 2023, 5:18 p.m.