mat2dbTab: Formatting an ecological site x species matrix into a...

Usage Arguments Value Author(s) See Also Examples

View source: R/mat2dbTab.R

Usage

1
mat2dbTab(mat)

Arguments

mat

Ecological site x species matrix. Sites (locations) should be rows, species columns

Value

A data frame with the colums "SU" (sampling units), "sp" (species) and "ab" abundance.

Author(s)

Bottin, Marius

See Also

dbTab2mat

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.
matSp<-matrix(sample(c(0,1),100,replace=T,prob=c(.7,.3)),nrow=10,ncol=10,dimnames=list(paste("site",1:10,sep=""),paste("sp",1:10,sep="")))
mat2dbTab(matSp)
## The function is currently defined as
function (mat) 
{
    W <- which(mat > 0, arr.ind <- T)
    dbTab <- data.frame(SU = rownames(mat)[W[, "row"]], sp = colnames(mat)[W[, 
        "col"]], ab = mat[W])
    dbTab <- dbTab[order(dbTab$SU, dbTab$sp), ]
    return(dbTab)
  }

marbotte/marbotte_util documentation built on May 21, 2019, 9:35 a.m.