harmonize_roles: Align detected variable roles across sites

View source: R/harmonize_roles.R

harmonize_rolesR Documentation

Align detected variable roles across sites

Description

Runs detect_roles() name-blind on each site and reports, per role, which column each site holds, plus descriptive consistency checks (value type, event coding, group-label overlap, range overlap, battery size). Alignment is by role only; column names appear only in the returned cells. The residual covariate role is excluded from map, checks and site_only. aligned means the detector found the role at every site; it does not establish that the columns measure the same thing; read checks (levels, Jaccard, ranges) before pooling. Cell order is alphabetical and carries no pairing direction.

Usage

harmonize_roles(sites)

## S3 method for class 'role_harmonization'
print(x, ...)

## S3 method for class 'role_harmonization'
summary(object, ...)

Arguments

sites

A named list (unique, non-empty names) of at least two data.frames.

x, object

A role_harmonization object.

...

Ignored.

Value

An object of class "role_harmonization": a list with map (role, status, one column per site), checks (role, check, one column per site, flag), site_only (site, role, columns), n_sites and sites. Flags are type_mismatch, coding_mismatch and size_mismatch; no numeric threshold decides a flag. summary returns map.

Examples

set.seed(1)
mk <- function(n) data.frame(id = seq_len(n), arm = sample(c("a", "b"), n, TRUE),
                             x = rnorm(n), y = rnorm(n))
harmonize_roles(list(north = mk(60), south = mk(80)))

rolescry documentation built on Oct. 21, 2026, 5:14 p.m.