Skip to contents

Core functions

Main functions for creating and manipulating longitudinal skeletons

create_skeleton()
Create longitudinal data skeleton
add_onetime()
Add one-time data to skeleton
add_annual()
Add annual data to skeleton

Medical data integration

Functions for adding medical registry data

add_diagnoses()
Add diagnosis data to skeleton
add_operations()
Add surgical operation data to skeleton
add_icdo3s()
Add ICD-O-3 oncology codes to skeleton
add_snomed3s()
Add SNOMED-CT version 3 codes to skeleton
add_snomedo10s()
Add SNOMED-CT version 10 codes to skeleton
add_rx()
Add prescription drug data to skeleton
add_cods()
Add cause of death data to skeleton
add_quality_registry()
Add quality registry data to skeleton

Data transformation

Functions for transforming data structure and creating derived variables

make_rowind_first_occurrence()
Transform a row-dependent variable to a row-independent variable using first occurrence

Survival analysis

Helper functions for time-to-event and survival analysis

steps_to_first()
Calculate steps until first TRUE in a forward window
any_events_prior_to()
Check for any TRUE values in a prior window

Target trial emulation

Functions and classes for causal inference using target trial emulation methodology

TTEDesign
TTEDesign class for target trial emulation
TTEPlan
TTEPlan class for trial generation planning
TTEEnrollment
TTEEnrollment class for target trial emulation
tteplan_apply_derived_confounders()
Compute derived confounder columns from a study spec
tteplan_apply_exclusions()
Apply exclusion criteria from a study spec to a skeleton
tteplan_from_spec_and_registrystudy()
Create a TTEPlan from a study specification
tteplan_load()
Load a TTEPlan from disk with the current class definition
tteplan_locate_and_load()
Locate and load a TTEPlan from candidate directories
tteplan_read_spec()
Read and validate a YAML study specification
tteplan_validate_spec()
Validate spec variables against skeleton data
tteenrollment_combined_combine()
Combine rates + IRR outputs into a single wide publication-ready table
tteenrollment_impute_confounders()
Impute missing confounders by sampling from observed values
tteenrollment_irr_combine()
Combine and format multiple irr outputs into a publication-ready table
tteenrollment_rates_combine()
Combine and format multiple rates outputs into a publication-ready table
tteenrollment_rbind()
Combine multiple enrollment objects
skeleton_eligible_age_range()
Check eligibility based on age range
skeleton_eligible_combine()
Combine multiple eligibility criteria
skeleton_eligible_isoyears()
Check eligibility based on ISO years
skeleton_eligible_no_events_in_window_excluding_wk0()
Check eligibility based on no events in prior window (excluding baseline week)
skeleton_eligible_no_events_lifetime_before_and_after_baseline()
Check eligibility based on no events ever (person-level, before and after baseline)
skeleton_eligible_no_observation_in_window_excluding_wk0()
Check eligibility based on no observation of a specific value (excluding baseline week)

Parallel processing

Parallel batch processing via processx

parallel_pool()
Run a function on each work item in parallel via processx
setup_progress_handlers()
Install a progressr handler that works in interactive R and RStudio jobs

Skeleton pipeline

RegistryStudy + Skeleton R6 classes and functions for batched skeleton processing

RegistryStudy
RegistryStudy: Unified R6 class for skeleton pipeline
Skeleton
Skeleton: per-batch time grid + derived columns with provenance
registrystudy_load()
Locate and load a RegistryStudy from candidate metadata directories
create_skeleton()
Create longitudinal data skeleton
validate_skeleton_structure()
Validate skeleton structure

Multi-host path resolution

CandidatePath R6 class + helpers for resolving directories that live at different locations on different hosts

CandidatePath
CandidatePath: a directory with multiple candidate locations
first_existing_path()
First candidate path that exists
invalidate_candidate_paths()
Invalidate every CandidatePath cache inside an R6 object

Utility functions

Helper functions for data processing

fread_raw()
Read a raw registry file with fread, then lowercase names
qs2_read()
Read a qs2 file (auto-detecting format)
make_lowercase_names()
Convert column names to lowercase and optionally clean date columns
parse_swedish_date()
Parse Swedish registry dates
first_non_na()
Get first non-NA value from vector
last_non_na()
Get last non-NA value from vector
min_with_infinite_as_na()
Calculate minimum while treating infinite values as NA
max_with_infinite_as_na()
Calculate maximum while treating infinite values as NA
as_logical_min_with_infinite_as_na()
Convert minimum to logical while treating infinite values as NA
as_logical_max_with_infinite_as_na()
Convert maximum to logical while treating infinite values as NA

Specialized functions

Functions for specific research applications

x2023_mht_add_lmed()
Add 2023 MHT-specific prescription data to skeleton
x2026_mht_add_lmed()
Add 2023 MHT-specific prescription data to skeleton

Datasets

Synthetic registry data for development and examples