Class "rwi" holds ring-width indices: detrended series with one
series per column and one year per row, as made by
detrend, rcs and cms.
as.rwi labels a data.frame or matrix of indices
as one.
as.rwi(x)# S3 method for rwi
[(x, i, j, drop)
# S3 method for rwi
subset(x, subset, select, drop = FALSE, ...)
# S3 method for rwi
time(x, ...)
# S3 method for rwi
summary(object, ids = NULL, pcrit = 0.05, ...)
# S3 method for summary.rwi
print(x, max.print = 10, ...)
# S3 method for summary.rwi
as.data.frame(x, ...)
# S3 method for rwi
plot(x, plot.type = c("spag", "seg", "image"), ...)
as.rwi: an object of class c("rwi", "data.frame").
x is returned unchanged if it already has that class.
time: a numeric vector of years.
summary: an object of class "summary.rwi", a list with
how (the dplR.detrend record), n.series,
first, last, common (the first and last years
in which every series has a value, or NA), stats (from
rwi.stats), ids.given, empty (the names of series with no values),
series (the per-series data.frame)
and pcrit.
for as.rwi, a data.frame or
matrix with series as columns and years as row names; for the
methods, an object of class "rwi", or of class
"summary.rwi" for print and as.data.frame.
an optional data.frame grouping the series by tree,
with columns tree and core, one row per series, as for
rwi.stats (see read.ids). NULL
counts each series as its own tree.
the significance level below which a series is taken to correlate with the others.
the most series to list as not correlating.
as for [.rwl and
subset.rwl.
"spag" for spag.plot,
"seg" for seg.plot, or "image" for a
heat map of the indices. See Details.
for plot, passed to the plotting function; for
plot.type = "image" this includes clip, the quantile
at which the colours are clipped (default 0.99), and arguments to
image. Otherwise not used.
Andy Bunn
An "rwi" object has the same shape as an "rwl" object
and makes the same promise: the row names are the years, consecutive
and increasing. It does not inherit from "rwl", so that
indices and ring widths can be told apart.
dplR's functions use the class to check what they are given. Those
that want ring widths -- detrend, rcs,
cms, i.detrend, bai.in,
bai.out, pointer,
strip.rwl, ssf and
rwl.report -- warn when given an "rwi" object,
and say what goes wrong: detrend on indices, for instance,
divides out a growth curve that has already been removed. Those that
want indices -- chron, chron.ars,
chron.stabilized, rwi.stats,
rwi.stats.running and sss -- warn when
given an "rwl" object: rwi.stats(ca533) gives an
rbar.eff of 0.350 from the widths against 0.423 from the
Spline indices, and nothing about the number says it is wrong. They
still take a plain data.frame or matrix without a word, and a
"bai" object of basal area increment (see
as.bai). The
crossdating functions, the plots, common.interval,
sgc and rwl.stats take either class
quietly. Each warning is only a warning, and the function goes on:
if the class is what is wrong -- indices read from a file with
read.rwl come back as class "rwl" -- relabel
them with as.rwi, or relabel widths with as.rwl.
Two attributes travel with it. attr(x, "dplR.detrend") is a
list that says how the indices were made: the function
(fun), the method and its settings, and always
difference, which is TRUE when the indices are
differences from the fitted curve (centred on 0) rather than ratios
(centred on 1). attr(x, "dplR.provenance") is the provenance
record of the ring widths the indices were made from, if they had one
(see read.tucson). Neither is set by as.rwi,
which only labels the object.
Subsetting works as for "rwl" objects ([.rwl):
the class and both records are kept, dropping series trims the years
that none of the remaining series cover, and a row subset that leaves
the years out of order or with holes returns a plain
data.frame, with a warning. subset and
window.rwi drop series left with no values and name
them in a message; [ keeps them, on purpose, so that its
columns stay lined up with anything indexed alongside them.
summary describes the indices as a collection. It gives how
they were made (from attr(x, "dplR.detrend")), their span and
common interval, the collection statistics from
rwi.stats (including rbar.eff, EPS and SNR), and for
each series its first and last years, length, mean, standard
deviation, first-order autocorrelation, and its correlation with the
mean of the other series, with the p-value, from
interseries.cor with its defaults. Printing it shows
the collection and lists the series that do not correlate with the
others at pcrit; as.data.frame gives the per-series
table. The collection statistics count each series as its own tree
unless ids is given, and the print says which. The print ends
by pointing to summary with ids (when it was not
given),
rwi.stats.running (rbar and EPS through time, which
usually fall off where sample depth does) and
corr.rwl.seg (where in a series the fit breaks down).
A series with no values at all is listed and left out of the
collection statistics, the correlations and the common interval. With
fewer than two series with values there is no collection, and the
statistics and correlations are NULL and NA.
plot draws, by default, spag.plot, which draws
indices around 1 (or 0 for differences) and not around each series'
mean, so the grey line under each series is the value the indices
should sit at. plot.type = "image" draws each index as a
coloured cell, with years across and series down, earliest-starting
at the bottom. Colours are brown below 1 (or 0) and green above it.
Each side is scaled separately and clipped at the clip
quantile of its departures, since ratio indices cannot fall below 0
but can run well above 2; the key gives the clips. A run of one
colour at the start or end of a series is a growth trend the
detrending did not remove, and a vertical stripe is a year the series
agree on.
Arithmetic on an "rwi" object (e.g. x + 1) returns a
plain data.frame, as it does for any data.frame
subclass. Use as.rwi on the result if it is still a set of
indices.
detrend, rcs, cms,
as.rwl, chron, rwi.stats
library(utils)
data(ca533)
ca533.rwi <- detrend(ca533, method = "Spline")
class(ca533.rwi)
str(attr(ca533.rwi, "dplR.detrend"))
summary(ca533.rwi)
## Group cores by tree, from the series IDs
summary(ca533.rwi, ids = autoread.ids(ca533))
head(as.data.frame(summary(ca533.rwi)))
plot(ca533.rwi[, 1:5])
data(co021)
## The growth trend "Mean" leaves in: a run of green at the start of
## nearly every series.
plot(detrend(co021, method = "Mean"), plot.type = "image")
Run the code above in your browser using DataLab