R/sahrlocs2niche.r

"sahrlocs2niche" <- function(x, ani=names(x$hr),
                             var=names(x$sa), used=c("hr", "locs"))
{
    ## Verifications
    used<-match.arg(used)
    if (!inherits(x,"sahrlocs"))
        stop("non convenient data")

    ## The "available" table
    output<-list()
    sa<-getsahrlocs(x)
    sa<-sa[var]
    hr<-x$hr[ani]
    locs<-x$locs[ani]
    class(sa)<-c("kasc", "data.frame")
    e<-kasc2df(sa)
    output$tab<-e$tab
    output$index<-e$index

    ## The "use" table
    if (used=="hr") {
        Y<-hr
        for (i in 1:ncol(hr)) Y[is.na(Y[,i]),i]<-0
    }
    if (used=="locs") Y<-locs
    Y<-Y[e$index,]
    output$y<-as.data.frame(Y)

    ## The output
    return(output)
}

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.