Solution 6: Functional code and packages

Functional packages

# Pseudocode to generate a cohort from Vandelay data based on demographic
#   diagnosis, biomarker, and follow-up time inclusion criteria


# Create a connection to the data
connect_vandelay(path = "path/to/vandelay/data") |>

# Start a breast cancer cohort
cohort_start(type = "breast") |>

# Define index date to be the date of metastatic diagnosis
define_index(index_date = "metastatic_diagnosis_date") |>

# Add patient's biomarker status for the biomarker "x" at index
add_biomarker_status_at_index(bm_name = "x") |>

# Add followup time to last visit
add_followup_time(censor = "last_visit") |>

# Define inclusion criteria
add_inclusion(sex = "female"
              age_at_index >= 18,
              x_status = "Positive",
              followup_time >= months(6)) |>

# Create a table 1
add_table_one(vars = c("sex", "age_at_index", "x_status", "followup_time")
Example R code for a fictional package “vandelay” describing a functional workflow to define a bespoke cohort, and create a table 1 from Vandelay data.

Functional code, such as R and Python packages, designed specifically to help users implement common workflows with your data, can be incredibly useful for software developers. These packages provide pre-written code that can be easily integrated into new projects, allowing developers to focus on building new features rather than re-writing code that already exists. In addition, using pre-existing code can help to ensure that new projects are reliable and well-tested, since the packages they rely on have already been used by many other developers. By leveraging existing code in this way, developers can save time and effort while still producing high-quality software for their users.