Data Source Agnostic Filtering Tools
Overview
Common API for filtering data stored in different data models. Provides multiple filter types and reproducible R code. Works standalone or with 'shinyCohortBuilder' as the GUI for interactive Shiny apps.
Breaking changes
- **Filter system rewritten to S7.** Filters are now S7 objects (e.g.
CbFilterDiscrete,CbFilterRange) with dual dispatch on (filter_class, source_class). Properties are accessed via@instead of closure environments. New S7 generics:cb_filter_data(),cb_get_filter_stats(),cb_plot_filter_data(),cb_get_filter_data(),cb_get_filter_defaults(),cb_filter_to_expr(). - Removed
def_filter(),new_filter(), and.as_constructor()— replaced by S7 constructors. - Switched from magrittr
%>%to native pipe|>. Requires R >= 4.1.0. - Renamed the cohort statistics store and its API for clarity: the
Cohort$new()cacheargument is nowcompute_stats, thepropagate_domainsmode"cache"is now"stats", and theget_cache()/update_cache()methods are nowget_stats()/update_stats(). The previous live-computation methodCohort$get_stats()(used bystat()) is nowcalc_stats().
New features
Show all changes in 1.0.0Hide the rest of the changes in 1.0.0
- Custom filter types can now be registered via
register_filter_type(), enabling extensions without modifying core package code. - New
describe()helper to attach metadata (descriptions) to datasets and filters.describe()also accepts alabelargument; when set on a variable,autofilter()reuses it as the generated filter'sname. shape()filter entries now include anamefield, and thedescriptionfield combines the filter- and variable-level descriptions.- New
shape()generic extracts structured filter/dataset metadata from a source, including statistics (min/max for range, choices for discrete). - New
autofilter()generic auto-generates filters based on column types (character/factor → discrete, numeric → range, Date → date_range, POSIXct → datetime_range). Supportsattach_as = "step"(add as filtering step) orattach_as = "meta"(store as available filters). - New
.classparameter intblist()to prepend custom S3 classes for method dispatch customization. - Steps now track
pendingstatus — only pending steps trigger statistics recalculation, improving performance for multi-step workflows. update_filter()now supports pre/post hooks viahook_args.- New
Cohort$new()propagate_domainsargument controls how filter domains are narrowed between steps:"none"(default),"filter"(from previous step filter values),"stats"(from stored statistics; requirescompute_stats = TRUE), or"data"(scan filtered data; the stats-free equivalent). Backed by the.propagate_domains()source method and the S7 genericscb_intersect_domain(),cb_intersect_domain_values(),cb_domain_from_stats(), andcb_domain_from_data(). Filter values are now intersected against their domain (with trimming messages) before filtering. set_source()gains acompute_meta_statsargument (default from thecb.source_filters_meta_statsoption) controlling whether metadata statistics foravailable_filtersare pre-computed; whenFALSE, filter domains fall back to live computation. Sources also accept anavailable_filtersdefinition directly.- Filter ids are now deterministic by default (derived from dataset and variable names), enabling cross-step filter matching for domain propagation. Override with explicit
id =.
AI/LLM integration
- New
cb_tool()system for defining LLM-compatible tool specifications (requiresellmer). - Built-in tools:
cb_tool_filters_meta(),cb_tool_add_filters(),cb_tool_set_filter_values(),cb_tool_apply_filters()(combined add + set values). cb_register_tool()andcb_register_tools()register tools with anellmerchat object.- AI tool invocations can be traced by setting
options(cb_tool_verbose = TRUE), which logs the invoked tool and its arguments viamessage(). Logging is off by default (replaces earlier unconditionalprint()debug output).
Improvements
- Use
collapsefor binding operations (joins), withverboseoption for diagnostics. - Reorganized
breaksargument for date_range filter plots. - Extensive test coverage improvements including vdiffr snapshot tests for all filter plot types.
cohort()now exposes thecompute_statsandpropagate_domainsarguments, andadd_filter()/rm_filter()now expose and forward thehookargument (previously these were silently ignored).- Comprehensive roxygen documentation added across exported and internal functions, plus a new
source-intelligencevignette coveringdescribe(),autofilter(),shape(), and the AI/LLM tools.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK14 OK2026-03-10
Documentation
- Help pages
- 85 (3 internal)includes a package overview page
- Examples that run
- 75%6 run in a plain check · 2 never run
- Exported functions with examples
- 11%
- Documented parameters
- 95%
- Return-value docs
- 83%
- Help pages citing references
- 0%
Downloads
Repository
- PRs merged (all time)
- 100%
- Median days to close, 50 most recently updated closed issues
- 307
- Median days to close, 50 most recently updated closed PRs
- 7
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
12 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/r-world-devs/cohortbuilder on 2026-10-11.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-07-10 · The repository has a site deploy workflow
pkgdown site last built 2026-07-10
Show all practicesHide 2 practices
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-05-27Seen in the repository: .claude, .claude/skills, CLAUDE.mdNamed in .Rbuildignore: .claude, CLAUDE.md
Dependencies
Installing cohortBuilder adds 33 packages (18 with compiled code, 33 MB of source tarballs). Heaviest: stringi 11 MB, ggplot2 6.0 MB, Rcpp 1.8 MB.
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- 1.0.0Latest2026-07-03 · current release · diff ↗ ·
removed 10 exports
.as_constructor, cb_filter.date_range, cb_filter.datetime_range, cb_filter.discrete, cb_filter.discrete_text, cb_filter.multi_discrete, cb_filter.query, cb_filter.range, def_filter, new_filteradded 43 exports
.propagate_domains, CbFilter, CbFilterDateRange, CbFilterDatetimeRange, CbFilterDiscrete, CbFilterDiscreteText, CbFilterMultiDiscrete, CbFilterQuery, CbFilterRange, autofilter, cb_domain_from_data, cb_domain_from_stats, cb_filter_data, cb_filter_to_expr, cb_get_filter_data, cb_get_filter_defaults, cb_get_filter_stats, cb_intersect_domain, cb_intersect_domain_values, cb_plot_filter_data, cb_register_tool, cb_register_tools, cb_tool, cb_tool_add_filters, cb_tool_apply_filters, cb_tool_clear_filters, cb_tool_describe_state, cb_tool_filters_meta, cb_tool_get_code, cb_tool_get_data_summary and 13 more - RR 4.6.0 released · 2026-04-24
- 0.4.0
- RR 4.5.0 released · 2025-04-11
- 0.3.0
- RR 4.4.0 released · 2024-04-24
- RR 4.3.0 released · 2023-04-21
- 0.2.0
- 0.12022-06-01
- RR 4.2.0 released · 2022-04-22
Package metadata
- First published
- 2022-06-01
- Total releases
- 5 / 4 yrs
- License
- MIT + file LICENSE OSI
- Minimum R
- ≥ 4.1.0
- Bundled data
- 3.0 KB / 1 file
- Download size
- 887 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("cohortBuilder")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-19, which the citation names so these numbers can be found later. More on citing and the projects behind them.