[New Package] sleepcleanr: Auditable pipeline for messy sleep diary data

Hi Posit community!

I'm releasing sleepcleanr, an R package for reproducible, auditable
cleaning of sleep diary data collected via intensive longitudinal research
(ecological momentary assessment / EMA).

The problem

Sleep diary timestamps seem simple, but real-world data is messy:

  • AM/PM swaps: "got up at 23:45" (typo?) vs actual 11:45 PM
  • Duration entry errors: 120 minutes entered as "02:00" (HH:MM instead of MM)
  • Temporal violations: "fell asleep at 11:00 PM but went to bed at midnight"
  • Self-report noise: ±75 min variance in sleep onset latency across
    duplicate reports

What sleepcleanr does differently

sleepcleanr flags problems for human review rather than silently
auto-fixing:

  • 1,048 flagged records (out of 13,990) → human review
  • 0 silent corrections
  • Every change logged in reversible CSV ledgers
  • Full audit trail: who changed what, when, why

Validation

Built on a 9-step validation chain:

  1. Synthetic benchmarks: 0.995 recall on injected errors
  2. Real-world redundancy: 92% agreement between duplicate diary entries
  3. Robustness: multiverse analysis + seed stability proof
  4. Methods documented: long + short forms, publication-ready figures

308 unit tests passing. All code audited for correctness.

Quick start

install.packages("sleepcleanr")
library(sleepcleanr)

# Demo on synthetic data
run_pipeline()

# Your own study: YAML config, no code changes
file.copy(system.file("config_template.yaml", package = "sleepcleanr"),
          "my_study.yaml")
# Edit my_study.yaml → run_pipeline(config = "my_study.yaml")

Output

  • Dataset A: Final clean data (1,048 flagged records corrected)
  • Dataset B: Full audit ledger (what changed, why)
  • 30+ figures: QC plots + research-ready visualizations

Why transparent cleaning matters

In behavioral science, we need to know:

  • Which records are flagged and why
  • What corrections were made
  • Who made them
  • Whether they're reversible

This builds trust with reviewers and co-authors. No black boxes.

Links

For researchers using EMA / intensive longitudinal methods

If you collect sleep diaries, movement logs, mood assessments, or any
timestamp-based self-report data, this architecture (detect → review → log)
is generalizable beyond sleep.

Feedback very welcome! Questions about validation, extensibility, or
methods?