Topic: Abundance

Topic Description:

Functions for calculating total abundance or basal area of trees or stems in forest censuses, allowing user chosen grouping variables such as species names, diameter categories, or quadrats. The functions are designed for the standard CTFS R Analytical Tables.



File: abundance/abundance.r

View File Source Download File No help file available

Function: pop.change.dbh

Function Description: pop.change.dbh

Finds abundance or basal area in two censuses and the rate of change between them, in several dbh categories. Accepts two dataframes, each an R Analytical Table for one census, the earlier census first. Only one additional splitting variable (other than dbh category) is allowed. Typically, this is species, but genus or quadrat are other examples.

The return value is a list of two elements, one name abund (or ba) and the other meandate, just as other abundance results. Each is a table having one pair of columns for every dbh category: the first for census 1, the second for census 2. So if there are 3 dbh categories, the table has 6 columns. The rows of the table are the splitting variable (eg, species).

Function Arguments:

ArgumentDefault Value
census1
census2
type'abund'
dbhunit'mm'
alivecodec("A")
classbreakc(10,100,300)
splitNULL

Arguments Description:

See abundance()


Sample Usage:

Nchange=pop.change.dbh(bci.full5,bci.full6,classbreak=c(10,100,300))
Nchange$abund
BAchangePerSpp=pop.change.dbh(bci.full5,bci.full6,classbreak=c(10,100),split=bci.full5$sp)
head(BAchangePerSpp$ba)


Function Source:


pop.change.dbh=function(census1,census2,type='abund',dbhunit='mm',alivecode=c("A"),classbreak=c(10,1
        00,300),split=NULL) {
if(is.null(split)) split=rep("all",dim(census1)[1])
allsplit=sort(unique(split))

allbreak=c(classbreak,10000)
alldbhcat=paste(allbreak[-length(allbreak)],allbreak[-1],sep=".")
nocats=length(alldbhcat)

dbhclass1=as.numeric(as.character(cut(census1$dbh,breaks=allbreak,right=FALSE,labels=classbreak)))
dbhclass2=as.numeric(as.character(cut(census2$dbh,breaks=allbreak,right=FALSE,labels=classbreak)))


part1=abundance(census1,type=type,dbhunit=dbhunit,alivecode=alivecode,split1=split,split2=dbhclass1
        )
part2=abundance(census2,type=type,dbhunit=dbhunit,alivecode=alivecode,split1=split,split2=dbhclass2
        )
abund1=fill.dimension(part1[[1]],class1=allsplit,class2=classbreak)
abund2=fill.dimension(part2[[1]],class1=allsplit,class2=classbreak)
date1=fill.dimension(part1$meandate,class1=allsplit,class2=classbreak,fill=NA)
date2=fill.dimension(part2$meandate,class1=allsplit,class2=classbreak,fill=NA)

if(!is.null(split))
cols=as.vector(t(outer(classbreak,1:2,paste,sep="_")))
else cols=paste("all",1:2,sep="_")

abund=data.frame(abund1[,1],abund2[,1])
meandate=data.frame(date1[,1],date2[,1])

if(nocats>1)
for(j in 2:nocats)
{
abund=data.frame(abund,abund1[,j],abund2[,j])
meandate=data.frame(meandate,date1[,j],date2[,j])
}

colnames(abund)=colnames(meandate)=cols
rownames(abund)=rownames(meandate)=allsplit

result=list(abund=abund,meandate=meandate)
if(type=='ba') names(result)[1]='ba'
else if(type=='agb') names(result)[1]='agb'

return(result)
}