Skip to contents

Return the preset_spec last attached via set_preset(), or NULL when no session default has been set. The cascade resolver calls this internally; users call it for diagnostics ("what is my session inheriting?") or to copy the active default into a per-spec override via preset().

Usage

get_preset()

Value

A preset_spec, or NULL when no session default is active.

See also

Session-scope setter: set_preset().

Per-spec partner: preset().

Entry / terminal verbs: tabular(), emit(), as_grid().

Examples

# ---- Example 1: Inspect after setting a session default ----
#
# `get_preset()` returns NULL before any session default has been
# attached, then returns the `preset_spec` after `set_preset()`.
get_preset()  # NULL
#> NULL

set_preset(font_size = 8, orientation = "landscape")

active <- get_preset()
is_preset_spec(active)     # TRUE
#> [1] TRUE
active@font_size            # 8
#> [1] 8
active@orientation          # "landscape"
#> [1] "landscape"

# ---- Example 2: Copy the session default into a per-spec override ----
#
# Read the session preset, tweak one knob for a single table, and
# attach as a per-spec override without disturbing the session.
set_preset(font_size = 9, paper_size = "letter")

# Read-tweak-attach without mutating the session default.
base_knobs <- get_preset()
tabular(cdisc_saf_n) |>
  preset(
    font_size   = base_knobs@font_size,
    paper_size  = base_knobs@paper_size,
    orientation = "landscape"
  )
armarm_shortn
Placeboplacebo86
Xanomeline Low Dosedrug_5096
Xanomeline High Dosedrug_10072
TotalTotal254
# Reset the session default so subsequent examples / R sessions # are not affected. set_preset(.reset = TRUE)