| char_smooth | R Documentation |
Applies one of five smoothing methods to the interpolated charcoal
accumulation rate series (charcoal$accI) and stores the result in
charcoal$accIS. Mirrors CharSmooth.m from the MATLAB v2.0
codebase.
char_smooth(charcoal, pretreatment, smoothing, results = NULL, plot_data = 0L)
charcoal |
Named list with elements |
pretreatment |
Named list with element |
smoothing |
Named list with elements:
|
results |
Named list (not used in R; kept for API symmetry). |
plot_data |
0/1 flag; ignored in R (no diagnostic plots). |
## Smoothing methods
| Index | Name | Implementation |
|——-|——|—————-|
| 1 | Lowess | [char_lowess()] with iter = 0 |
| 2 | Robust Lowess | [char_lowess()] with iter = 4 |
| 3 | Moving average | zoo::rollapply(..., mean, partial=TRUE) |
| 4 | Running median + Lowess | Shifted-window median loop, then [char_lowess()] |
| 5 | Running mode + Lowess | Shifted-window 100-bin mode loop, then [char_lowess()] |
## Span convention
The smoothing window width in data-point units is
s = smoothing$yr / pretreatment$yrInterp. This is passed to
[char_lowess()] as span = s (number of points), which
converts it to the fraction required by stats::lowess() via
f = round(s) / N.
## NaN bridging
NaN values in accI (from record gaps) cannot be passed to
[char_lowess()] directly. They are bridged by linear interpolation
before smoothing and restored afterward, matching the MATLAB fallback
path in CharSmooth.m (used when the Curve Fitting Toolbox is
absent). Methods 4 and 5 always use the bridged series.
## Window selection for methods 4 and 5
The boundary window is SHIFTED (not shrunk) to maintain exactly
round(s) samples, matching MATLAB's loop logic. Note that
MATLAB's round() rounds 0.5 away from zero while R uses banker's
rounding (round half to even); this can cause single-sample differences
in window boundaries for odd half-integers.
The input charcoal list with an additional element
accIS: the smoothed C_background series (length N).
[char_lowess()], [CharAnalysis()]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.