# https://github.com/r-lib/pkgdown/issues/2704

Skip to contents

A function used to calculate the number of risk factors the patient has. This is used to calculate the pretest probability of coronary artery disease (CAD) based on the ESC 2024 guidelines.

Usage

calculate_esc_2024_num_of_rf(
  have_family_history,
  have_smoking_history,
  have_dyslipidemia,
  have_hypertension,
  have_diabetes,
  max_na = 0,
  label_have_family_history_no = c("no"),
  label_have_family_history_yes = c("yes"),
  label_have_family_history_unknown = c(NA, NaN),
  label_have_smoking_history_no = c("no"),
  label_have_smoking_history_yes = c("yes"),
  label_have_smoking_history_unknown = c(NA, NaN),
  label_have_dyslipidemia_no = c("no"),
  label_have_dyslipidemia_yes = c("yes"),
  label_have_dyslipidemia_unknown = c(NA, NaN),
  label_have_hypertension_no = c("no"),
  label_have_hypertension_yes = c("yes"),
  label_have_hypertension_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_unknown = c(NA, NaN),
  error_call = rlang::caller_env()
)

Arguments

have_family_history

The value of variable in the parameters label_have_family_history_no, label_have_family_history_yes and label_have_family_history_unknown.

have_smoking_history

The value of variable in the parameters label_have_smoking_history_no, label_have_smoking_history_yes and label_have_smoking_history_unknown.

have_dyslipidemia

The value of variable in the parameters label_have_dyslipidemia_no, label_have_dyslipidemia_yes and label_have_dyslipidemia_unknown.

have_hypertension

The value of variable in the parameters label_have_hypertension_no, label_have_hypertension_yes and label_have_hypertension_unknown.

have_diabetes

The value of variable in the parameters label_have_diabetes_no, label_have_diabetes_yes and label_have_diabetes_unknown.

max_na

Input integer 0 to 5 to indicate the maximum number of missing risk factors to tolerate before outputting an NA. Default: 0

label_have_family_history_no

Label(s) for patient with no family history of CAD. Default: c("no")

label_have_family_history_yes

Label(s) for patient having family history of CAD. Default: c("yes")

label_have_family_history_unknown

Label(s) for patient having unknown family history of CAD. Default: c(NA, NaN)

label_have_smoking_history_no

Label(s) for patient with no smoking history (current or past). Default: c("no")

label_have_smoking_history_yes

Label(s) for patient having smoking history (current or past). Default: c("yes")

label_have_smoking_history_unknown

Label(s) for patient having unknown smoking history (current or past). Default: c(NA, NaN)

label_have_dyslipidemia_no

Label(s) for patient with no dyslipidemia. Default: c("no")

label_have_dyslipidemia_yes

Label(s) for patient having dyslipidemia. Default: c("yes")

label_have_dyslipidemia_unknown

Label(s) for patient having unknown dyslipidemia. Default: c(NA, NaN)

label_have_hypertension_no

Label(s) for patient with no hypertension. Default: c("no")

label_have_hypertension_yes

Label(s) for patient having hypertension. Default: c("yes")

label_have_hypertension_unknown

Label(s) for patient having unknown hypertension. Default: c(NA, NaN)

label_have_diabetes_no

Label(s) for patient with no diabetes. Default: c("no")

label_have_diabetes_yes

Label(s) for patient having diabetes. Default: c("yes")

label_have_diabetes_unknown

Label(s) for patient having unknown diabetes. Default: c(NA, NaN)

error_call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

Value

An integer indicating the number of risk factors the patient has. It can also be NA if the number of missing risk factors exceeds the max_na input value.

Examples

calculate_esc_2024_num_of_rf(
  have_family_history = "yes",
  have_smoking_history = "yes",
  have_dyslipidemia = "yes",
  have_hypertension = "yes",
  have_diabetes = "no"
)
#> [1] 4

calculate_esc_2024_num_of_rf(
  have_family_history = "no",
  have_smoking_history = "no",
  have_dyslipidemia = "no",
  have_hypertension = NA,
  have_diabetes = "no",
  max_na = 0
)
#> [1] NA

calculate_esc_2024_num_of_rf(
  have_family_history = "no",
  have_smoking_history = "no",
  have_dyslipidemia = "no",
  have_hypertension = NA,
  have_diabetes = "no",
  max_na = 1
)
#> [1] 0