cohortBuilder 1.0.0
CRAN release: 2026-07-03
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
- 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.
cohortBuilder 0.4.0
CRAN release: 2026-02-24
- Multi discrete filter does not operate on
dplyr::acrossanddplyr::cur_columnanymore. - Now cohort calculates only active filters cache while initializing source (results with significant performance improvement). The
get_cachemethod computes cache when called (and the related cache was missing). - Add new
datatime_filterthat handle POSIXct type. - Move unique/distinct to
collapse::funique. - Replace (internally)
%in%with custom operator usingcollapse::fmatch, that seems to be more efficient.
cohortBuilder 0.3.0
CRAN release: 2024-09-25
- Add new filter of type
"query"that allows to configure complex filtering rules withqueryBuilderpackage. - Add filter-focused
.print_filtermethod responsible for printing filter values when callingsum_upon cohort.
cohortBuilder 0.2.0
CRAN release: 2023-02-28
- Changed the way reproducible code is returned. Now more flexibility is allowed with using e.g.
.repro_code_tweakmethod. - The
tblistsource reproducible code is now using pipe chains for each dataset filtering. - Optimized filtering with having cache computed only for active filters.
- Properly readjust steps and filters ids after step is removed.
- Add
.post_bindingmethod, that allows to modify data object when binding is completed. - Fix reproducible code generation when no filters applied.
