treeMean {dplR}R Documentation

Calculate mean across cores in a tree

Description

This function calculates the mean value for each tree in a rwl or rwi object.

Usage

treeMean(rwl, ids, na.rm=FALSE)

Arguments

rwl

a data.frame of ring widths with rownames(rwl) containing years and colnames(rwl) containing each series ID such as produced by read.rwl

ids

a data.frame with column one named "tree" giving a numeric ID for each tree and column two named "core" giving a numeric ID for each core.

na.rm

logical passed to rowMeans. Should missing values be removed?

Details

This function averages together multiple cores to give a mean value of growth. It is very common in dendrochronology to take more than one core per tree. In those cases it is occassionally desirable to have an average of the cores. This function merely loops through the rwl object and calculates the rowMeans for each tree. If na.rm=TRUE trees with >1 sample will be averaged only over the period where the samples overlap. If FALSE the output can vary in the number of samples. See examples.

Value

An object of class c("rwl", "data.frame") with the mean annual value for each tree.

Author(s)

Andy Bunn. Patched and improved by Mikko Korpela.

See Also

read.rwl, read.ids

Examples

data(gp.rwl)
gp.ids <- read.ids(gp.rwl, stc = c(0, 2, 1))

gp.treeMean <- treeMean(gp.rwl, gp.ids)
gp.treeMean2 <- treeMean(gp.rwl, gp.ids, na.rm=TRUE)

# look at an example of a single tree with different averaging periods
tree40 <- data.frame(gp.rwl[, c("40A","40B")],
                     gp.treeMean[, "40", drop=FALSE],
                     gp.treeMean2[, "40", drop=FALSE])
names(tree40) <- c("coreA", "coreB", "treeMean1", "treeMean2")
head(tree40,50)

data(ca533)
ca533.treeMean <- treeMean(ca533, autoread.ids(ca533))
# plot using S3method for class "rwl"
plot(ca533.treeMean,plot.type="spag")


[Package dplR version 1.7.6 Index]