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

Data transformation

Functions for transforming data structure and creating derived variables

make_rowind_first_occurrence()
Transform rowdep variable to rowind 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_read_spec()
Read and validate a YAML study specification
tteplan_validate_spec()
Validate spec variables against skeleton data
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

Functions for parallel batch processing with callr

callr_pool()
Run a function on each work item via a pool of persistent callr sessions
callr_kill_workers()
Kill orphaned swereg callr worker sessions

Skeleton pipeline

RegistryStudy R6 class and functions for batched skeleton processing

RegistryStudy
RegistryStudy: Unified R6 class for skeleton pipeline
create_skeleton()
Create longitudinal data skeleton
skeleton_save()
Save a skeleton batch to disk
skeleton_checkpoint()
Create a profiling checkpoint closure
validate_skeleton_structure()
Validate skeleton structure

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