char_parameters: Read CharAnalysis parameter and data files

View source: R/char_parameters.R

char_parametersR Documentation

Read CharAnalysis parameter and data files

Description

Reads the *_charParams.csv (or .xlsx) parameter file and the companion charcoal data file, then unpacks all analysis parameters into named lists that mirror the MATLAB struct layout.

Usage

char_parameters(file_name)

Arguments

file_name

Path to the *_charParams.csv (or .xlsx) parameter file.

Details

**CSV convention** (unchanged from MATLAB v1.1): the parameter file is named <site>_charParams.csv and the companion data file is <site>_charData.csv in the same directory. The site name is the basename with the trailing _charParams.csv (15 characters) removed, mirroring MATLAB's fileName(1:end-15) idiom.

**Parameter vector layout**: column 3 ("Parameters") of the CSV, rows 2-26 (25 data rows after the header), maps to positions 1-25 of the internal charParams vector exactly as in the MATLAB codebase. Unused zoneDiv slots are filled with -9999 in the CSV (sentinel) or NaN in Excel; both are stripped before the list is returned.

Value

A named list with elements:

char_data

Numeric matrix (n_samples x 6+): cmTop, cmBot, ageTop, ageBot, charVol, charCount.

pretreatment

List: zoneDiv, yrInterp, transform.

smoothing

List: method, yr.

peak_analysis

List: cPeak, threshType, threshMethod, threshValues, minCountP, peakFrequ, bkgSens.

results

List: saveFigures, save, allFigures.

site

Character string: site name derived from the filename stem.

See Also

[char_validate_params()], [char_pretreatment()], [CharAnalysis()]

Examples

# Read a bundled example parameter file:
params_file <- system.file("validation", "CO_charParams.csv",
                           package = "CharAnalysis")
p <- char_parameters(params_file)
p$pretreatment$yrInterp   # interpolation interval (yr)
p$smoothing$method        # smoothing method index (1-5)

CharAnalysis documentation built on May 3, 2026, 5:06 p.m.