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_cancer_without_morphology()
Add cancer diagnoses by topography (site only, ignoring morphology)
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 calendar 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
tte_stage()
Run one target trial emulation pipeline stage
tte_s0_flags()
Read the command-line flags of a project's s0_init.R
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_check_spec()
Check a YAML study specification and list every problem
tteplan_excel_spec_summary()
Write the specification workbook from a spec, without a plan
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_osf_text()
Write the OSF preregistration text that a spec determines
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_fill_aggregates()
Count the missing follow-up confounder values of a trial panel
tteenrollment_fill_followup_confounders()
Carry the last observed confounder value forward through follow-up
tteenrollment_fill_summary()
Report what the follow-up confounder fill changed
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

Progress handlers and worker-count helpers for parallel batch processing

setup_progress_handlers()
Install a progressr handler for interactive R and for job logs
default_n_workers()
Resolve the default number of parallel workers for a pipeline stage

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 standard-format qs2 file
qs2_write_atomic()
Atomically write an object to a qs2 file
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

Datasets

Synthetic registry data for development and examples