← Back to all sparks
F

fmtr

ANALYTICS
Velocity0.0

Easily Apply Formats to Data

Rebuilding SAS's formatting layer in R, one format specification at a time

sas-paritydata-formattingclinical-reportingformat-cataloguesr-package
Current state
fmtr applies formats to R data the way SAS applies them: named format catalogues, format lists, and an fapply() that maps a specification onto a vector. It is part of a family of packages that reconstruct SAS reporting idioms in R, and it shares infrastructure with them — labels.data.frame() was moved out to the common package, which fmtr now depends on. The recent releases have been closing specific gaps against SAS's own format vocabulary.
Where it's heading
The direction is parity, pursued in small increments. Quarter format codes were added because base R has none; the SAS best. format was reimplemented, then hardened against the variations people actually write; statistical summary helpers like fmt_mean_sd() and fmt_mean_stderr() cover the cell contents clinical tables need. The structural work is largely behind it, including the breaking 2022 move that handed labelling to a sibling package, so what remains is vocabulary coverage.
Prediction
The pattern of adding a SAS format, then a release to handle its variants, suggests the next releases continue filling in format codes and summary helpers rather than changing how formats are applied.

Recent moves

  1. 10mo ago

    Mean and standard error helper, plus best-format variants

    Adds fmt_mean_stderr() alongside the existing mean and standard deviation helper, and handles the variations on the best specification that the previous release did not anticipate. The standard one-two of this package: add a SAS-derived format, then absorb how people actually write it.

    View source ↗
  2. 11mo ago

    SAS best. format reimplemented in fapply()

    Recreates SAS's best. format, which picks a sensible numeric representation without the caller specifying width or decimals. A direct parity addition of the kind that defines this package's roadmap.

    View source ↗
  3. 2y ago

    Quarter format codes %q and %Q added

    Introduces quarter format codes that base R simply does not provide, filling a gap that matters for any reporting on fiscal periods. Small in size, but it extends the format vocabulary rather than adjusting existing behaviour.

    View source ↗
  4. 2y ago

    Format lists become readable and writable files

    Adds read.flist() and write.flist() so format lists persist to disk, allows single-item vector lookups, and lets a Factor column drive the as.factor property when converting data frames. Persisting format catalogues is what makes them reusable across programs, which is how they work in SAS.

    View source ↗
  5. 2y ago

    Documentation and examples expanded

    Documentation and example improvements with no functional change. Notable only as the quiet gap between the 2023 and mid-2024 feature releases.

    View source ↗
  6. 2y ago

    value() can return results as a factor

    Adds an as.factor parameter to value() so formatted results come back as factors, which controls ordering downstream in tables and plots. The same property later became settable from a data frame column.

    View source ↗