check.rwl is for functions that want ring widths. If
rwl is an "rwi" object of ring-width indices (see
as.rwi), a warning names the calling function, says
that it wants widths, adds why, and suggests
as.rwl if the values really are widths. The object is
then relabelled as class "rwl" and checked as below. A
"bai" object of basal area increment (see as.bai)
is treated the same way, unless bai.ok is TRUE, when it
is relabelled without a warning.
If rwl is not already of class "rwl", coercion is
attempted using as.rwl. If coercion succeeds, a warning
is issued. If coercion fails (e.g., because row names are not
consecutive integers, columns are not numeric, or the input is not a
data.frame or matrix), the function stops with a single
informative message that describes both the class problem and the
reason coercion failed.
After class validation, each series is checked for internal
NA values, defined as NA values that are sandwiched
between non-NA values within a series (as opposed to leading
or trailing NAs, which are standard in rwl objects).
If any are found, a warning names the affected series and suggests
fill.internal.NA.
This function is called at the top of the dplR functions that want
ring widths, providing uniform validation across the package.
Functions that take widths or indices alike, and those that want
indices, use internal checks of their own (see as.rwi).