ksCompare 0.2.4
New features — data validation engine
ks_check_rules(data, rules, mode)applies a declarative list of one-sided-formula rules row-wise and records acheck_msgslist-column. Two modes:"first"(stops at first failure per row, fast) and"all"(collects every failing message per row, thorough).ks_collapse_check_msgs(data, col)collapses thecheck_msgslist-column produced byks_check_rules()to a plain character column, with a configurablesepargument.ks_check_summary(data, col)returns a named list with two tibbles:overview(total / passing / failing rows and pass rate) andviolations(per-message counts and percentages, sorted descending). No file is written.ks_check_report_html(data, path, ...)renders a self-contained HTML check report usinghtmltoolsandreactable— no Quarto, no Pandoc. Follows the samepath = NULL / NA / "file.html"routing asks_report_html(). Sections: KPI cards, violation summary table, row-detail table with OK / Issue status badges.ks_compare_check_state(current, previous, key_cols, compare_cols)diffs two successiveks_check_rules()runs and tags every row as"new","changed", or""(unchanged). Designed for iterative QC workflows where only rows that regressed or improved need attention.ks_save2xlsx_by(data, file, colors, split_col, msg_col, ...)writes a grouped Excel workbook with one worksheet per unique value ofsplit_coland applies conditional row highlighting based on substrings inmsg_col. Built onopenxlsx2for modern Excel output.
ksCompare 0.2.3
New features
-
ks_compare()gains aloglevelparameter to control console output verbosity. - Comparison result object gains a
verdictslot for pipeline integration.
ksCompare 0.2.0
Performance
- Row matching for duplicate-key strategies
keep_allandall_pairs(ks_match_rows_keep_all(),ks_match_rows_all_pairs()) now pre-allocates the per-group parts list and caches the level factor used for splitting, removing O(n^2) list-copy churn on data sets with many unique keys. - The main comparison loop in
ks_compare()now pre-allocates thevalue_partsaccumulator and usesorder(..., method = "radix")for the final stable sort ofvalue_diff, materially speeding up wide comparisons (many matched column pairs) and large diff tables. -
ks_schema_diff()no longer rescansmeta_b$name/meta_c$namefor every column pair; it builds a name-indexed lookup once and reuses per-row metadata, and it hoists thecompare_labels/compare_formatsoption checks out of the per-column loop. -
ks_value_diff_one()now slices the unequal cells once and reuses the result forks_explain_diffs(),format_cell(), andks_na_flow(), avoiding three redundant subsets on large columns; the type-mismatch branch likewise slicesbase_col/comp_colonly once.
ksCompare 0.1.0
- Initial development release. ksCompare is a tidyverse-native engine for comparing two data frames in the spirit of SAS
PROC COMPARE, with extensions for clinical/pharma workflows. Highlights:-
ks_compare()orchestrator with explicitbykeys,by = "auto"uniqueness inference, and explicit columnmapping. -
ks_tol()with absolute, relative, and ULP tolerance plus per-column overrides. -
ks_comp_options()for NA semantics, SAS special-missing handling, label/format comparison, string trim/case/normalize toggles, and an optionalpaththat pins every downstreamks_report_*()artefact to a single output folder. Every field also falls back to agetOption("ksCompare.<arg>")global, andks_set_comp_options()forwards tooptions()for project-wide defaults. -
ks_comparisonS3 withprint(),summary(),as_tibble(),ks_tidy(),ks_glance(). - Per-type cell diff for numeric (with ULP-aware compare), character, factor, date/datetime, and
haven_labelledcolumns; encoding-safe string comparison. - Schema diff including label and SAS-format mismatches; format comparison is trailing-dot- and case-tolerant so haven import artefacts do not surface as false diffs.
- Manifest with input hashes and package version for QC traceability.
-
as_outbase(),as_outcomp(),as_outdif(),as_outnoequal()helpers reshape diffs into PROC COMPARE-style tibbles, plusks_sysinfo()for a SAS-compatible bitmask. - Smart features: auto-key inference, fuzzy column rename suggestions (Suggests-gated on
stringdist), duplicate-key strategies (first,last,keep_all,all_pairs,error), and pattern detection (constant_offset,constant_scale,sign_flip,integer_round,whitespace_only,trim_only,case_only,factor_recoded). - Reports:
ks_report_html()(self-containedhtmltools+reactablepage with sticky TOC, KPI cards, status pill, themed tables, an optionalgroup_by_keymode that renders one collapsed block per key value, and a print-friendly stylesheet) andks_report_xlsx()(openxlsx2 multi-sheet workbook with conditional formatting onOUT_DIF). The HTML report inlines every JS/CSS dependency into a single file, so no siblinglib/folder is written next to the report. - I/O:
ks_read_sas()/ks_read_xpt()(haven wrappers preserving labelled metadata) andks_read_arrow()(Parquet / Feather). - Ecosystem:
ks_assert_clean()pipeline gate withks_pointblank_step()adapter;as_ks_comparison()generic with method forarsenal::comparedf. - Documentation: pkgdown site, five long-form vignettes (
getting-started,from-proc-compare,smart-features,reports,pipeline-gates), and CI workflows forR-CMD-check,pkgdown, andtest-coverage.
-
