Skip to content

docs: guard fetwfe()/betwfe() bacondecomp examples with requireNamespace (#260)#263

Merged
gregfaletto merged 1 commit into
mainfrom
docs-guard-bacondecomp-examples-260
Jun 6, 2026
Merged

docs: guard fetwfe()/betwfe() bacondecomp examples with requireNamespace (#260)#263
gregfaletto merged 1 commit into
mainfrom
docs-guard-bacondecomp-examples-260

Conversation

@gregfaletto

Copy link
Copy Markdown
Owner

Refs #260.

fetwfe() and betwfe()'s primary runnable @examples opened with a bare
library(bacondecomp) + data(castle). bacondecomp is a Suggests-only
dependency, so example(fetwfe) / example(betwfe) errored with
there is no package called 'bacondecomp' for any user without it installed.
(R CMD check --as-cran installs Suggests, so the check itself was always clean —
this only bit interactive example() use.)

Fix

Wrap each of the two affected example bodies in
if (requireNamespace("bacondecomp", quietly = TRUE)) { ... }. With bacondecomp
present (including under R CMD check) the example runs exactly as before; without
it, the example is silently skipped instead of erroring.

Scope — deliberately just two examples

Only fetwfe() and betwfe() have un-guarded, runnable bacondecomp examples.
The other estimator examples are intentionally left untouched:

  • etwfe()'s bacondecomp example is already inside \dontrun{} (never runs → no
    problem).
  • fetwfeWithSimulatedData() / etwfeWithSimulatedData() /
    betwfeWithSimulatedData() use genCoefs() / simulateData() and do not use
    bacondecomp at all
    , so they must NOT be gated on it.

(This is the narrowly-correct implementation of #260. The open drive-by PR #262
applied the bacondecomp guard to all six examples — including the three
simulateData-based ones that don't use bacondecomp — which is incorrect; this
PR supersedes it.)

Bookkeeping

Gate results

  • air format .: clean.
  • devtools::document(): regenerated only man/fetwfe.Rd + man/betwfe.Rd; no drift.
  • devtools::test(): [ FAIL 0 | WARN 0 | SKIP 0 | PASS 3351 ].
  • R CMD check --as-cran: 0 errors | 0 warnings | 0 notes (Status OK), fetwfe 1.26.1.

🤖 Generated with Claude Code

…ace (#260)

fetwfe() and betwfe()'s primary runnable @examples opened with a bare
library(bacondecomp) + data(castle). bacondecomp is a Suggests-only dependency,
so example(fetwfe) / example(betwfe) errored ("there is no package called
'bacondecomp'") for users without it installed. (R CMD check --as-cran installs
Suggests, so the check was always clean -- this only bit interactive example() use.)

Wrap each of the two affected example bodies in
`if (requireNamespace("bacondecomp", quietly = TRUE)) { ... }`: with bacondecomp
present (including under R CMD check) the example runs exactly as before; without
it, it is silently skipped instead of erroring.

Scope is deliberately just these two examples. etwfe()'s bacondecomp example is
already inside \dontrun{} (never runs), and the three *WithSimulatedData examples
use genCoefs()/simulateData() -- not bacondecomp -- so they are intentionally left
untouched (gating them on bacondecomp would be wrong). Only man/fetwfe.Rd and
man/betwfe.Rd regenerate.

Version 1.26.0 -> 1.26.1; the NEWS 1.26.1 section also documents the #257
doc-clarity fix (twfeCovs estimand wording + genCoefs @param G "Optional") that
merged via #259 without a NEWS entry.

devtools::test(): FAIL 0 | WARN 0 | SKIP 0 | PASS 3351.
R CMD check --as-cran: 0 errors | 0 warnings | 0 notes.

Refs #260.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant