Skip to content

cat2cat

0.6.1Package record

Handling an Inconsistently Coded Categorical Variable in a Longitudinal Dataset

0packages depend
4.2Kdownloads / year
99.7%test coverage
13/13flavors OK

Overview

About

Unifying an inconsistently coded categorical variable between two different time points in accordance with a mapping table. The main rule is to replicate the observation if it could be assigned to a few categories. Then using frequencies or statistical methods to approximate the probabilities of being assigned to each of them. This procedure was invented and implemented in the paper by 'Nasinski', 'Majchrowska', and 'Broniatowska' (2020) doi:10.24425/cejeme.2020.134747.

Changes in 0.6.1

This release incorporates feedback from the PhD dissertation reviewers: dr hab. Andrzej Dudek, dr hab. Joanna Landmesser-Rusek, and dr hab. Paweł Andrzej Strzelecki.

New features

  • New occup_panel dataset - a rotational panel covering 2009Q1--2010Q4 - used to illustrate id_var direct matching and to exercise the panel-data code path in tests.
  • Naive Bayes ("nb") added to the supported ML methods, via e1071 (Suggests).
  • summary_c2c() now supports both lm and glm, adds input/shape validation (df_old/df_new, coefficient table checks), and reports the reference distribution used for p-values (t or normal). Added edge-case tests and aligned regression/panel vignette examples with current summary_c2c() output and fixed-effects inference guidance.
  • cat2cat_ml_run() now reports the Brier score and mean P(true class) in addition to accuracy. A proper scoring rule matters because cat2cat weights are *probabilities*, not classifications - a model can be accurate and still be poorly calibrated.
  • All stopifnot() assertions now carry descriptive messages, so failures point the user at the offending argument instead of printing the raw expression.
  • cat2cat() ML fallback is now configurable via ml$on_fail ("freq", "naive", "na", "error") with optional warning control via ml$fail_warn. Failed ML weights are now explicitly handled according to this policy instead of always silently falling back to frequency weights.
  • cat2cat() ML now accepts factor features in addition to numeric/logical: factor columns listed in ml$features are automatically one-hot encoded using the union of levels observed in ml$data and the target period.

Documentation

  • Vignettes reorganised into three clearer guides: *Get Started*, *Choosing Weights and Validating ML*, and *Advanced Workflows*. The goal is a cleaner reader path: core concepts first, method choice second, advanced workflows third.
  • *Get Started* now focuses on the two-period workflow, core assumptions, and the value added of cat2cat for group-level longitudinal analysis, with sharper pointers to the more advanced guides.
Show all changes in 0.6.1Hide the rest of the changes in 0.6.1
  • *Choosing Weights and Validating ML* is now structured as a decision guide: understanding weight assumptions, checking robustness across methods, validating ML against naive/frequency baselines, and handling failed ML predictions.
  • *Advanced Workflows* now collects ML setup, multi-period chaining, rotational panels with id_var, aggregated-data workflows, hierarchical-code mappings, and regression/inference after harmonisation into one better-structured advanced reference.
  • Added a *When cat2cat won't help* section distinguishing hard blockers (no mapping table, unobserved category) from method-specific limitations with available workarounds.
  • Corrected the $R^2$ guidance: ordinary $R^2$ is preserved in neutral replication cases when replicated copies keep the same response/covariates and weights sum back to the source observation; adjusted $R^2$, AIC, and BIC require original-scale degrees-of-freedom care, and fit statistics with harmonised-category covariates are conditional on the chosen weights.
  • Roxygen for cat2cat() and cat2cat_agg() trimmed - argument documentation kept, conceptual material moved to the vignettes where it belongs.

Bug fixes

  • Fixed the nomnoml diagram that previously mislabelled the base/target sides under forward mapping.
  • Fixed get_freqs() for r-devel/R CMD check: replaced as.data.frame(table(...)) conversion with direct data.frame(input = names(tab), Freq = as.integer(tab)) construction to avoid failures when NA appears in table names (row names contain missing values).

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 10.8 min · r-oldrel-macos-x86_64
Status changes
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK13 OK2026-06-09
  • ERROR12 OK, 1 ERROR2026-06-08
  • OK13 OK2026-05-09
Show 2 earlier changesHide 2 earlier changes
  • ERROR12 OK, 1 ERROR2026-05-03
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 0.6.1
README· In the repository, left out of the releaseVignettesYes · 3 · dynamicNEWSYes · 100% structured · mentions 0.6.1Citation fileYes · cites a publicationWebsiteYes · pkgdown
Help pages
22 (5 internal)
Examples that run
67%10 run in a plain check · 1 only when donttest examples are enabled (R CMD check --as-cran) · 4 never run
Exported functions with examples
100%
Documented parameters
80%
Return-value docs
100%
Help pages citing references
0%

Downloads

4.2K
CRAN downloads in the past year
Rank #6,184 · ~11/day · ~346/mo
Daily download trend is not available in this view yet.
52730 days
1.4K90 days
4.2K1 year
Compare downloads with other packages →
Also on191 r2u9 autocran

Repository

5Stars
1Forks
7Open issues
0Open PRs
4Releases
120Commits
1Commit identities
factorcategoriespanelencodingencodingstransitionsmappingsmapping
License file reads as GPL-2.0 · 120 commits · Last activity 2026-05-17 · Default branch at 0.6.1.9000, ahead of CRAN 0.6.1 (checked 2026-10-22)
Responsiveness
How these are sampled
PRs merged (all time)
88%
Median days to close, 50 most recently updated closed issues
39
Median days to close, 50 most recently updated closed PRs
3

Stars over time

2025-07-18 · 52026-07-07 · 5
PracticesBeta

10 development-tooling and community-health practices detected across 7 families in the upstream repository

Checks run against github.com/polkas/cat2cat on 2026-10-22.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Governance and community (1)
Contributing guide
Docs source (3)
pkgdown

GitHub Pages site last deployed 2026-05-17 · The repository has a site deploy workflow

pkgdown site last built 2026-05-17

Coverage (1)
Coverage reporting
Show all practicesHide 3 practices
CRAN release process (1)
cran-comments.md
Research and citation (1)
codemeta.json
Lint, format, editor (1)
RStudio project
How this is detected·Detection ruleset v4 (2026-10-20)

Dependencies

Declared dependencies
12 external dependencies (excludes base and recommended)

Installing cat2cat adds no packages beyond those that come with R.

Depends (1)
R >= 3.6
Imports (1)
MASS
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
0direct
0indirect

Nothing depends on this yet.

Datasets

People & History

People (1)
Author, Maintainer since 0.1.3 (2020)
Releases (13)

Pick two releases to compare their code metrics.

Show 4 earlier eventsHide 4 earlier events
  • 0.2.0
    record
    2020-12-08 · diff ↗ ·
    removed 2 exports
    cross_cat2cat, prune_cat2cat
    added 3 exports
    cross_c2c, plot_c2c, prune_c2c
  • 0.1.7
    record
    2020-11-29 · diff ↗
  • 0.1.3
    record
    2020-09-22
  • R
    R 4.0.0 released · 2020-04-24

Package metadata

First published
2020-09-22
Total releases
13 / 6 yrs
License
GPL (>= 2) | file LICENSE OSI
Minimum R
≥ 3.6
Bundled data
2.2 MB / 6 files
Download size
2.4 MB

Cite

Cite this package

Run in R for the authors' entry:

citation("cat2cat")

The package provides a citation file, so citation() returns the authors' own entry.

It points to 10.1016/j.softx.2023.101525.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for cat2cat version 0.6.1 [Data set]. HJJB, LLC. Data release v2026-10-24. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-24, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy