R/colasc.r

"colasc" <- function(x, ...)
  {
      ## Verifications
      if (!inherits(x, "asc"))
          stop("Should be an \"asc\" object")

      ## the list of colors with levels of maps
      l<-list(...)
      n<-names(l)
      i<-NA

      ## levels of the map
      tc<-levels(x)

      ## Verifications that the names of "..." correspond to the
      ## levels of x
      for (i in n) {
          if (!any(tc==i))
              stop(paste(i, "is not a valid level of the factors"))
      }

      ## creates the vector of colors
      coul<-0
      for (i in 1:length(tc)) {
          u<-tc[i]
          coul[i]<-l[[u]]
      }
      return(coul)
  }

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.