R/as.asc.r

"as.asc" <- function(x, xll=1, yll=1, cellsize=1,
                     type=c("numeric", "factor"),
                     lev=levels(factor(x)))
{
    ## Verifications
    type<-match.arg(type)
    if (!inherits(x, "matrix"))
      stop("x should be a matrix")

    ## creates the attributes
    mode(x)<-"numeric"
    attr(x, "xll")<-xll
    attr(x, "yll")<-yll
    attr(x, "cellsize")<-cellsize
    attr(x, "type")<-type
    if (type=="factor")
      attr(x, "levels")<-lev
    class(x)<-"asc"

    ## Output
    return(x)
  }

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.