## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(echo = TRUE, comment = "#>")
library(pft)

## -----------------------------------------------------------------------------
patient <- data.frame(
  Sex      = "M",
  Age_y    = 45,
  Ht_cm    = 178,
  Ancestry = "Caucasian"
)

# Bare names (tidyverse-style)
pft_spirometry(patient,
               sex    = Sex,
               age    = Age_y,
               height = Ht_cm,
               race   = Ancestry)

# Strings -- equivalent
pft_spirometry(patient,
               sex    = "Sex",
               age    = "Age_y",
               height = "Ht_cm",
               race   = "Ancestry")

# Injection from a variable, e.g. driven by a config
sex_col <- "Sex"
pft_spirometry(patient, sex = !!sex_col,
               age    = Age_y,
               height = Ht_cm,
               race   = Ancestry)

## ----eval = FALSE-------------------------------------------------------------
# library(dplyr)
# patient %>%
#   rename(fev1_measured = FEV1_L,
#          fvc_measured  = FVC_L) %>%
#   pft_spirometry(year = 2022)

