# toy
n <- 100
# make three fake tree ring series to show that these funcs work on rwl objects
rwl <- data.frame(x1 = 0.75 + exp(-0.2*1:n) + abs(rnorm(n,0,0.05)),
x2 = 0.75 + exp(-0.2*1:n) + abs(rnorm(n,0,0.05)),
x3 = 0.75 + exp(-0.2*1:n) + abs(rnorm(n,0,0.05)))
# the inside out method
foo <- bai.in(rwl=rwl)
# the outside in method
bar <- bai.out(rwl=rwl)
# identical
head(bar)
head(foo)
# use gp data
data(gp.rwl)
data(gp.dbh)
# dbh (minus the bark) from cm to mm
gp.dbh2 <- gp.dbh[,1:2]
gp.dbh2[,2] <- (gp.dbh[,2] - gp.dbh[,3]) * 10
bar <- bai.out(rwl=gp.rwl,diam=gp.dbh2)
bar.crn <- chron(bar)
yr <- as.numeric(rownames(bar.crn))
plot(yr,bar.crn[,1],type='n',
xlab='Year', ylab=expression(mm^2))
lines(yr,bar.crn[,1],col='grey',lty='dashed')
lines(yr,ffcsaps(bar.crn[,1],nyrs=32),col='red',lwd=2)
Run the code above in your browser using DataLab