Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4f6f0ff
cleaned up instructions, next is PR2
antoniojbt Jun 14, 2026
0613613
active tests for branches
antoniojbt Jun 14, 2026
a061f83
added instructions for a second EDA based external truth test set, pe…
antoniojbt Jun 14, 2026
137afe3
prompt instructions, agent md, local R checks script
antoniojbt Jun 14, 2026
2c21e51
safer prompt loop
antoniojbt Jun 14, 2026
9abd72f
Add fixture-backed EDA contract tests
antoniojbt Jun 14, 2026
0faad62
Merge pull request #157 from antoniojbt:feature/pr2-eda-contracts
antoniojbt Jun 14, 2026
3444788
codex instructions
antoniojbt Jun 14, 2026
81b5ce7
added mamba env and dev tools
antoniojbt Jun 14, 2026
f496d4e
local env for checks
antoniojbt Jun 14, 2026
71050ed
PR3 complete for SDD for EDA flow
antoniojbt Jun 14, 2026
dd40d22
phase 1 wasn't done, will do later, SDD here
antoniojbt Jun 14, 2026
54132dc
clarified what 'fragile' helper functions means
antoniojbt Jun 14, 2026
7089f06
Add synthetic data fixture tests
antoniojbt Jun 15, 2026
130df97
Merge pull request #158 from antoniojbt/codex/find-next-step-for-eda-…
antoniojbt Jun 15, 2026
ba59d3e
Implement EDA synthetic data generation
antoniojbt Jun 15, 2026
4e9915e
Merge pull request #159 from antoniojbt/codex/review-eda-sdd-work-for…
antoniojbt Jun 15, 2026
e19d4d7
Add fixture tests for EDA summaries and plots
antoniojbt Jun 15, 2026
072317f
Merge pull request #160 from antoniojbt/codex/find-next-step-for-eda-…
antoniojbt Jun 15, 2026
56a39cb
Implement EDA summaries and plots
antoniojbt Jun 15, 2026
3fd6694
Merge pull request #161 from antoniojbt/codex/review-pr7-in-start-her…
antoniojbt Jun 15, 2026
3f736f0
Add run_eda fixture workflow tests
antoniojbt Jun 15, 2026
6619054
Merge pull request #162 from antoniojbt/codex/review-pr8-in-start-her…
antoniojbt Jun 15, 2026
3eae684
Implement run_eda orchestration
antoniojbt Jun 15, 2026
8ad90d4
Merge pull request #163 from antoniojbt/codex/locate-pr9-in-start-her…
antoniojbt Jun 15, 2026
86217ce
PR10 plus corrections to env calling and naming conventions
antoniojbt Jun 15, 2026
a4f99d5
PR11 EDA SDD reporting
antoniojbt Jun 15, 2026
c007a14
split pr12 for tdd then coding, pr14 is now large data, deferred
antoniojbt Jun 15, 2026
bdd52b2
pr13 for reporting template
antoniojbt Jun 15, 2026
f76e88f
docs for eda sdd flow
antoniojbt Jun 15, 2026
7c12c2a
cran pass and rd updates
antoniojbt Jun 15, 2026
4500736
Merge pull request #164 from antoniojbt:cran-checks-episcout2
antoniojbt Jun 15, 2026
c1adfef
re-org future work with sdd tdd, archived first phase
antoniojbt Jun 15, 2026
7e038a6
fixed 'backlog.md' remains
antoniojbt Jun 15, 2026
626120e
Merge pull request #165 from antoniojbt/future-dir-for-sdd-tdd
antoniojbt Jun 15, 2026
f85d61d
tests for edge cases for epi_stats functions
antoniojbt Jun 15, 2026
4e2cf39
bot review
antoniojbt Jun 15, 2026
59e777f
added todos in future, sdd tdd for review findings, started work on r…
antoniojbt Jun 15, 2026
7ff73f7
added todos and ideas for future work
antoniojbt Jun 15, 2026
764cc49
todos and agent, minor
antoniojbt Jun 16, 2026
79db47b
epi_sec function for pseudonym v1
antoniojbt Jun 18, 2026
10158aa
Merge pull request #168 from antoniojbt/epi_sec-v1
antoniojbt Jun 18, 2026
167ea24
Fix CodeFactor lint findings
antoniojbt Jun 18, 2026
3cc9b93
Merge pull request #171 from antoniojbt/codex/suggest-fixes-for-codec…
antoniojbt Jun 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
^archive$
^archive/
^future$
^future/
^codecov\.yml$
^cran-comments\.md$
^\.travis\.yml$
^\.DS_Store$
^data-raw$
^LICENSE\.md$
^episcout\.Rproj$
Expand All @@ -23,4 +28,8 @@
^AGENTS\.MD$
^fishers_results\.txt$
^spec_driven_EDA_plan$
^environment\.yml$
^scripts$
^build$
^legacy$
# .Rbuildignore
2 changes: 1 addition & 1 deletion .github/workflows/r-cmd-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

on:
push:
branches: [main, master]
branches: ["**"] #[main, master]
pull_request:
branches: [main, master]

Expand Down
2 changes: 1 addition & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
linters: linters_with_defaults(line_length_linter = line_length_linter(150), object_name_linter = object_name_linter(styles = "snake_case"), assignment_linter = assignment_linter(), spaces_left_parentheses_linter = spaces_left_parentheses_linter(), object_usage_linter = object_usage_linter(), commented_code_linter = NULL, indentation_linter(indent = 2L, hanging_indent_style = "always"))
exclusions: list("blurbs_and_old_code/*")
exclusions: list("blurbs_and_old_code/*", "scripts/rscript_env_caller.R")
122 changes: 99 additions & 23 deletions AGENTS.MD
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# AGENTS.md

This file defines conventions and instructions to guide OpenAI Codex and other agents in contributing to this R package.
It standardises formatting, documentation, testing, and pull request workflows.
It standardises code writing, formatting, documentation, testing, and pull request workflows.

It should be respected by automated agents at all times, particularly when:

* Writing new functions (must include roxygen2 and tests)
* Refactoring existing code (preserve naming and indentation)
* Editing documentation (run `devtools::document()`)
* Opening a PR (follow title/description/branch rules)
* Running checks (use scripts provided above)
* Debugging, identifying errors and making improvements

Do not overcomplicate and over-engineer. Prefer the simpler solution. Make it easy for a human to review, supervise and monitor work. Do not bloat file content or create numerous files when one would suffice. e.g. use one `TODOs.md`, not a dir with `now.md`, `next.md`, `later.md`.

When fixing code, identify the cause; do not simply fix the symptom.

Never hide behaviour behind 'clean up' when refactoring.

When writing tests, never mirror the implementation. Always test against the intended behaviour. If this is unclear, undocumented or may be wrong, always stop and report.

---

## 📁 Project Structure

Expand All @@ -17,6 +36,76 @@ It standardises formatting, documentation, testing, and pull request workflows.

---

## R Environment

Use the repo-local R wrapper for all R commands:

```bash
scripts/rscript_env_caller.R -e "R.home(); .libPaths()"
```

The wrapper resolves to the project mamba environment by default:

```text
~/apps/miniforge3/envs/episcout/bin/Rscript
```

Do not use bare `Rscript` unless you have verified it resolves to the
`episcout` mamba environment. To use a different R binary, set
`EPISCOUT_RSCRIPT`; see `scripts/rscript_env_caller.R`.

For `devtools` checks, set a real CRAN mirror inside the R expression. Do not
leave `repos` as the placeholder `@CRAN@`, because package checks may spend a
long time probing package repositories.

```bash
scripts/rscript_env_caller.R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); devtools::check(manual = FALSE)"
```

## Repo Script Discovery and Naming

Before adding or changing helper commands, inspect existing project entry
points:

```text
scripts/
Makefile
.github/workflows/
AGENTS.MD
```

Do not add a new helper script if an existing script already covers the task.
If an existing helper has an unclear or misleading name, propose a rename or
targeted cleanup instead of adding another wrapper.

Script names must describe the project action, not merely mirror a system
binary. Avoid names that are visually or semantically confusable with common
commands, such as:

```text
rscript
python
R
test
check
```

Prefer explicit project or task names such as:

```text
scripts/rscript_env_caller.R
scripts/check-local.sh
scripts/check-cran.sh
scripts/render-report.sh
```

Before adding a new script, confirm:

1. No existing script already does the job.
2. The name is unambiguous in chat, docs, logs and CI.
3. The script follows the repo's existing shell/R conventions.


## Coding Conventions

* Use `snake_case` for object and function names.
Expand Down Expand Up @@ -52,13 +141,13 @@ All new functions must include unit tests in `/tests/testthat/`.
Run tests locally before committing:

```bash
Rscript -e "devtools::test(reporter = 'summary')"
scripts/rscript_env_caller.R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); devtools::test(reporter = 'summary')"
```

Use `covr` to monitor test coverage:

```bash
Rscript -e "covr::report()"
scripts/rscript_env_caller.R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); covr::report()"
```

Ensure test coverage does not decrease for existing functions.
Expand All @@ -71,19 +160,19 @@ Always update documentation and verify build integrity before PRs.

```bash
# Regenerate documentation
Rscript -e "devtools::document()"
scripts/rscript_env_caller.R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); devtools::document()"

# Build the package tarball
R CMD build . --no-resave-data --compact-vignettes=gs+qpdf

# Run CRAN-like checks
R CMD check --no-manual --as-cran
scripts/rscript_env_caller.R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); devtools::check(manual = FALSE)"
```

Optional: rebuild vignettes manually

```bash
Rscript -e "devtools::build_vignettes()"
scripts/rscript_env_caller.R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); devtools::build_vignettes()"
```

---
Expand Down Expand Up @@ -127,10 +216,10 @@ Examples:
Run all checks **before requesting a review**:

```bash
Rscript -e "styler::style_pkg()"
Rscript -e "lintr::lint_package()"
Rscript -e "devtools::check(manual = FALSE)"
Rscript -e "covr::report()"
scripts/rscript_env_caller.R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); styler::style_pkg()"
scripts/rscript_env_caller.R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); lintr::lint_package()"
scripts/rscript_env_caller.R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); devtools::check(manual = FALSE)"
scripts/rscript_env_caller.R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); covr::report()"
```

All of the above must pass before merging.
Expand Down Expand Up @@ -161,16 +250,3 @@ act -j check # if act is installed for local testing
```

---

## Agent-Specific Instructions

This AGENTS.md should be respected by OpenAI Codex or other automated agents when:

* Writing new functions (must include roxygen2 and tests)
* Refactoring existing code (preserve naming and indentation)
* Editing documentation (run `devtools::document()`)
* Opening a PR (follow title/description/branch rules)
* Running checks (use scripts provided above)

---

13 changes: 10 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ Authors@R:
email = "antoniojberlanga@gmail.com")
Author: Antonio Berlanga-Taylor [aut, cre]
Maintainer: Antonio Berlanga-Taylor <antoniojberlanga@gmail.com>
Description: Facilitates cleaning, exploring and visualising large-ish datasets (hundreds of thousands to millions of observations with tens to hundreds of variables). These are mostly wrapper and convenience functions to pre-process (wrangle, explore, clean, etc.) data-sets. Assumes you're happy with tidyverse and the basics of data.table.
Description: Facilitates cleaning, exploring and visualising large-ish
epidemiological datasets (hundreds of thousands to millions of
observations with tens to hundreds of variables). Provides helper functions
for preprocessing and descriptive work, plus specification-first
exploratory data analysis workflows for epidemiological datasets. Assumes
you're happy with tidyverse and the basics of data.table.
License: GPL-3
Encoding: UTF-8
LazyData: true
Expand All @@ -17,6 +22,7 @@ Imports:
utils,
stats,
grDevices,
openssl,
magrittr,
rlang (>= 0.1.2),
broom,
Expand Down Expand Up @@ -52,7 +58,8 @@ Suggests:
covr,
withr,
roxygen2,
mice
mice,
targets
Roxygen: list(markdown = TRUE)
VignetteBuilder: knitr
RoxygenNote: 7.3.2
Config/roxygen2/version: 8.0.0
20 changes: 16 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ export(epi_clean_replace_value)
export(epi_clean_spread_repeated)
export(epi_clean_transpose)
export(epi_create_dir)
export(epi_eda_check_schema)
export(epi_eda_create_project)
export(epi_eda_generate_synthetic_data)
export(epi_eda_profile_missing)
export(epi_eda_profile_plots)
export(epi_eda_profile_summaries)
export(epi_eda_render_report)
export(epi_eda_run)
export(epi_eda_spec)
export(epi_eda_validate_spec)
export(epi_grob_to_excel)
export(epi_head_and_tail)
export(epi_list_head)
export(epi_list_tail)
Expand All @@ -47,9 +58,10 @@ export(epi_plot_parallel)
export(epi_plot_save_parallel)
export(epi_plot_theme_1)
export(epi_plot_theme_imss)
export(epi_plots_to_grid)
export(epi_plot_volcano)
export(epi_plots_to_grid)
export(epi_read)
export(epi_sec_pseudonym)
export(epi_stats_2x2_all)
export(epi_stats_2x2_cols)
export(epi_stats_2x2_test)
Expand Down Expand Up @@ -83,7 +95,6 @@ export(epi_utils_session)
export(epi_write)
export(epi_write_df)
export(expr)
export(epi_grob_to_excel)
export(palette_IMSS)
export(palette_IMSS_accessible)
export(quo)
Expand All @@ -105,8 +116,11 @@ importFrom(e1071,kurtosis)
importFrom(e1071,skewness)
importFrom(foreach,`%dopar%`)
importFrom(grDevices,boxplot.stats)
importFrom(graphics,abline)
importFrom(graphics,plot)
importFrom(magrittr,"%>%")
importFrom(magrittr,`%>%`)
importFrom(openssl,rand_bytes)
importFrom(rlang,":=")
importFrom(rlang,.data)
importFrom(rlang,enexpr)
Expand Down Expand Up @@ -141,5 +155,3 @@ importFrom(utils,capture.output)
importFrom(utils,head)
importFrom(utils,sessionInfo)
importFrom(utils,tail)
importFrom(graphics,abline)
importFrom(graphics,plot)
42 changes: 42 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# episcout News

## Development version

- Added `epi_sec_pseudonym()` to create secure participant pseudonymisation
bridge tables using cryptographic random tokens.
- Added a specification-first EDA workflow driven by data dictionaries:
`epi_eda_spec()`, `epi_eda_check_schema()`, `epi_eda_profile_missing()`,
`epi_eda_profile_summaries()`, `epi_eda_profile_plots()`,
`epi_eda_generate_synthetic_data()`, `epi_eda_run()`, and
`epi_eda_render_report()`.
- Added `epi_eda_create_project()` and a reusable project scaffold under
`inst/project-template/`.
- Added fixture-backed tests for the EDA workflow using a pinned
`blood_storage` fixture.
- Added an HTML EDA report template.
- EDA missingness and summaries now apply specification `missing_codes`.
- Categorical EDA summaries now include `p_observed` alongside the existing
total-row denominator `p`.
- Documented current MVP limits: basic summaries and plots, synthetic data for
pipeline preparation only, and no Arrow, DuckDB or data.table EDA backends yet.
- Cleaned up Rd documentation and CRAN-check issues on the development branch.

## 0.1.4

- Added `epi_plot_theme_imss` and colour palette helpers.
- Added `epi_plot_add_var_labels`.
- Reworked `epi_stats_*` summary functions.

## 0.1.3

- Improved coverage tests.
- Added helper wrappers.
- Improved documentation.

## 0.1.2

- Minor bug fixes and internal improvements.

## 0.1.1

- First release.
Loading
Loading