Topic: Growth

Topic Description:

Functions for analyzing tree growth, designed for the standard CTFS R Analytical Tables.



File: growth/growthfit.bin.r

View File Source Download File No help file available

Function: assembleBinOutput

Function Description: assembleBinOutput

Use the list output from piecewise regression (growthfit.bin) and converts to a flat table. The single argument inputdata is the output compare.growthbinmodel. Written by Adrian Das. (excluding burn in)

Function Arguments:

ArgumentDefault Value
inputtable
fulldata
sitename

Sample Usage:

bciresult=compare.growthbinmodel(linearbin.fit.trim3,export=NULL,makegraph=FALSE) bcitable=assembleBinOutput(bciresult,sitename='bci_12_spreadSD') write.table(bcitable,file='growth/BCIpiecewise.txt',quote=FALSE,sep='t',row.names=FALSE)


Function Source:

assembleBinOutput=function(inputtable,fulldata,sitename)
{
holder<-inputtable

spechold<-dimnames(holder$slope)[[1]]
maxbinhold<-apply(holder$slope, 1, function(x){length(x[is.na(x)==F])})

numbins<-length(holder$slopes[1,])
spp<-rownames(holder$slopes)
numspec<-length(spp)

holdcomb<-data.frame(spechold,maxbinhold)
rownames(holdcomb)=spp

dimnames(holdcomb)[[2]][1:2]<-c("Species","MaxBin")

for(i in 1:numbins)
{
holdcomb<-cbind(holdcomb,holder$slope[,i],holder$upper[,i],holder$lower[,i])

dimnames(holdcomb)[[2]][(3*i):(3*i+2)]<-c(paste("slope",i,sep=""),paste("upper",i,sep=""),past
        e("lower",i,sep="")) }

holdcomb$unit=holdcomb$sample=holdcomb$bigsample=NA

for(i in 1:numspec){
holdcomb$slopelast[i]<-holdcomb[spp[i],(holdcomb$MaxBin[i]*3)]
holdcomb$upperlast[i]<-holdcomb[spp[i],(holdcomb$MaxBin[i]*3+1)]
holdcomb$lowerlast[i]<-holdcomb[spp[i],(holdcomb$MaxBin[i]*3+2)]

if(!is.null(fulldata[[spp[i]]][[1]]$summary))
{
summ=fulldata[[spp[i]]][[1]]$summary
holdcomb[spp[i],c('sample','bigsample')]=c(summ$totalsample,summ$totalbig)
holdcomb[spp[i],'unit']=summ$dbhunit
}
}

holdcomb$site=sitename

return(holdcomb)
}