# Using the provided example data set:
# Expected units:
#   pf_ratio: PaO2 / FiO2
#     PaO2: mmHg
#     FiO2: decimal between 0.21 (room air) to 1.00 (pure oxygen)
#   sf_ratio: SpO2 / FiO2
#     SpO2: percentage, 0 to 100
#     FiO2: decimal between 0.21 (room air) to 1.00 (pure oxygen)
#   imv: (invasive mechanical ventilation) 1 for yes, 0 for no
#   other_respiratory_support: 1 for yes, 0 for no
phoenix_respiratory(
  pf_ratio = pao2 / fio2,
  sf_ratio = spo2 / fio2,
  imv      = vent,
  other_respiratory_support = as.integer(fio2 > 0.21),
  data = sepsis
)
# A set of values that will get all possible respiratory scores:
DF <- expand.grid(
  pfr = c(NA, 500, 400, 350, 200, 187, 100, 56),
  sfr = c(NA, 300, 292, 254, 220, 177, 148, 76),
  vent = c(NA, 0, 1),
  o2  = c(NA, 0, 1)
)
phoenix_respiratory(
  pf_ratio = pfr,
  sf_ratio = sfr,
  imv = vent,
  other_respiratory_support = o2,
  data = DF
)
Run the code above in your browser using DataLab