# Using the example sepsis data set, read more details in the vignette
phoenix8_scores <-
  phoenix8(
    # Respiratory
      pf_ratio = pao2 / fio2,
      sf_ratio = ifelse(spo2 <= 97, spo2 / fio2, NA_real_),
      imv = vent,
      other_respiratory_support = as.integer(fio2 > 0.21),
    # Cardiovascular
      vasoactives = dobutamine + dopamine + epinephrine + milrinone + norepinephrine + vasopressin,
      lactate = lactate,
      age = age, # Also used in the renal assessment.
      map = dbp + (sbp - dbp)/3,
    # Coagulation
      platelets = platelets,
      inr = inr,
      d_dimer = d_dimer,
      fibrinogen = fibrinogen,
    # Neurologic
      gcs = gcs_total,
      fixed_pupils = as.integer(pupil == "both-fixed"),
    # Endocrine
      glucose = glucose,
    # Immunologic
      anc = anc,
      alc = alc,
    # Renal
      creatinine = creatinine,
      # no need to specify age again
    # Hepatic
      bilirubin = bilirubin,
      alt = alt,
    data = sepsis
  )
str(phoenix8_scores)
Run the code above in your browser using DataLab