char_write_results: Write the CharAnalysis results matrix to a CSV file

View source: R/char_write_results.R

char_write_resultsR Documentation

Write the CharAnalysis results matrix to a CSV file

Description

Writes the N \times 33 char_results matrix (assembled by [char_post_process()]) to a CSV file whose column headers and numeric format match the MATLAB CharAnalysis v2.0 *_charResults.csv output exactly.

Usage

char_write_results(char_results, site, out_dir, digits = 7L)

Arguments

char_results

Numeric matrix (N \times 33) returned in out$char_results by [CharAnalysis()].

site

Character string: site name, used to build the output filename (<site>_charResults.csv).

out_dir

Directory in which to create the file. Required; no default. Created if it does not exist. Use tempdir() for a transient location, or supply a path of your choosing.

digits

Number of significant digits for numeric output. Default 7, matching MATLAB's fprintf default precision. Use NULL for R's full double precision (15 digits).

Details

## Column order and headers Columns follow the MATLAB charResults layout:

  1. cm Top_i (cm)

  2. age Top_i (yr BP)

  3. char Count_i (#)

  4. char Vol_i (cm3)

  5. char Con_i (# cm-3)

  6. char Acc_i (# cm-2 yr-1)

  7. charBkg (# cm-2 yr-1)

  8. char Peak (# cm-2 yr-1)

  9. thresh 1 (# cm-2 yr-1)

  10. thresh 2 (# cm-2 yr-1)

  11. thresh 3 (# cm-2 yr-1)

  12. thresh FinalPos (# cm-2 yr-1)

  13. thresh FinalNeg (# cm-2 yr-1)

  14. SNI (index)

  15. thresh GOF (p-val)

  16. peaks 1

  17. peaks 2

  18. peaks 3

  19. peaks Final

  20. peaks Insig.

  21. peak Mag (# cm-2 peak-1)

  22. smPeak Frequ (peaks 1ka-1)

  23. smFRIs (yr fire-1)

  24. nFRIs (#)

  25. mFRI (yr fire-1)

  26. mFRI_uCI (yr fire-1)

  27. mFRI_lCI (yr fire-1)

  28. WBLb (yr)

  29. WBLb_uCI (yr)

  30. WBLb_lCI (yr)

  31. WBLc (unitless)

  32. WBLc_uCI (unitless)

  33. WBLc_lCI (unitless)

## NA / empty handling NA values are written as empty fields (no quotes), matching MATLAB's blank-cell convention. This applies to:

  • smFRIs rows beyond the smoothed-FRI coverage window;

  • zone-statistics columns (24-33) for rows beyond the last zone;

  • any column not computed for a given run configuration.

## CI column convention MATLAB stores bootstrap CIs as [quantile(2.5%), quantile(97.5%)] in the columns labelled uCI / lCI respectively (i.e. uCI = lower bound, lCI = upper bound – MATLAB's own labelling is inverted). The R output follows the same convention so that column indices are identical to the MATLAB reference file.

Value

Invisibly returns the full path to the file written.

See Also

[char_post_process()], [CharAnalysis()]

Examples


  # Run the pipeline on the bundled example and write results to tempdir:
  params_file <- system.file("validation", "CO_charParams.csv",
                             package = "CharAnalysis")
  out <- CharAnalysis(params_file)
  char_write_results(out$char_results, out$site,
                     out_dir = tempdir())


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