Type: Package
Title: Pretest Probability for Coronary Artery Disease
Version: 1.1.0
Maintainer: Jeremy Selva <jeremy1189.jjs@gmail.com>
Description: An application to calculate a patient's pretest probability (PTP) for obstructive Coronary Artery Disease (CAD) from a collection of guidelines or studies. Guidelines usually comes from the American Heart Association (AHA), American College of Cardiology (ACC) or European Society of Cardiology (ESC). Examples of PTP scores that comes from studies are the 2020 Winther et al. basic, Risk Factor-weighted Clinical Likelihood (RF-CL) and Coronary Artery Calcium Score-weighted Clinical Likelihood (CACS-CL) models <doi:10.1016/j.jacc.2020.09.585>, 2019 Reeh et al. basic and clinical models <doi:10.1093/eurheartj/ehy806> and 2017 Fordyce et al. PROMISE Minimal-Risk Tool <doi:10.1001/jamacardio.2016.5501>. As diagnosis of CAD involves a costly and invasive coronary angiography procedure for patients, having a reliable PTP for CAD helps doctors to make better decisions during patient management. This ensures high risk patients can be diagnosed and treated early for CAD while avoiding unnecessary testing for low risk patients.
License: MIT + file LICENSE
URL: https://github.com/JauntyJJS/pretestcad, https://jauntyjjs.github.io/pretestcad/
BugReports: https://github.com/JauntyJJS/pretestcad/issues
Depends: R (≥ 4.1.0)
Imports: cli, dplyr, rlang, stringr
Suggests: purrr, spelling, testthat (≥ 3.0.0), tibble
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-GB
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2025-09-03 09:52:56 UTC; Jeremy
Author: Jeremy Selva ORCID iD [aut, cre]
Repository: CRAN
Date/Publication: 2025-09-03 11:40:02 UTC

Match an argument to a character vector but skip NA

Description

This is equivalent to arg_match but skip NA

Usage

arg_match0_allow_na(
  arg,
  values,
  arg_nm = rlang::caller_arg(arg),
  error_call = rlang::caller_env()
)

Arguments

arg

A symbol referring to an argument accepting strings.

values

A character vector of possible values that arg can take.

arg_nm

Same as error_arg.

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

The string supplied to arg.

See Also

caller_arg, stack, arg_match

Examples

# No error
input = "male"
arg_match0_allow_na(input, values = c("female","male"))

# Allow NA
input = NA
arg_match0_allow_na(input, values = c("female","male"))

# Error as M is not female or male
input = "emale"
try(arg_match0_allow_na(input, values = c("female","male")))

Match an argument to a integer vector but skip NA

Description

This is equivalent to arg_match but an integer variable is needed and skip NA.

Usage

arg_match0_integer(
  arg,
  values,
  allow_na = TRUE,
  arg_nm = rlang::caller_arg(arg),
  error_call = rlang::caller_env()
)

Arguments

arg

A symbol referring to an argument accepting strings.

values

A character vector of possible values that arg can take.

allow_na

Input boolean to determine if NA or NaN is allowed. Default: TRUE

arg_nm

Same as error_arg.

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

The integer supplied to arg.

Examples

# No error
input = 5
arg_match0_integer(input, values = c(0:5))

# Allow NA
input = NA
arg_match0_integer(input, values = c(0:5))

# Error as 0 is not within 0 and 5
input = 6
try(arg_match0_integer(input, values = c(0:5)))

# Error as NULL is not within 0 and 5
input = NULL
try(arg_match0_integer(input, values = c(0:5)))

# Error as NA is not within 0 and 5 and allow_na is FALSE
input = NA
try(arg_match0_integer(input, values = c(0:5), allow_na = FALSE))

Error Message For NA Argument For Non-missing List

Description

Provides an error message if the argument provided is NA if a non-missing list is provided

Usage

arg_match0_no_na_error_message(
  arg,
  values,
  arg_nm = rlang::caller_arg(arg),
  error_call = rlang::caller_env()
)

Arguments

arg

A symbol referring to an argument accepting strings.

values

A character vector of possible values that arg can take.

arg_nm

Same as error_arg.

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 error message if the argument provided is NA if a non-missing list is provided. Else if will return NULL invisibly, regardless if arg has a match with the elements in values or not.

See Also

caller_arg, stack cli_abort

Examples

# Error as input is NA but value list provided has no NA
input = NA
try(arg_match0_no_na_error_message(input, values = c("female","male")))

# No error as value list provided has NA
input = NA
arg_match0_allow_na(input, values = c("female","male", NA))

# No error as input is not NA
input = "male"
arg_match0_allow_na(input, values = c("female","male", NA))

Match an argument to a TRUE or FALSE vector but skip NA

Description

This is equivalent to arg_match but a boolean variable is needed and skip NA.

Usage

arg_match0_true_or_false(
  arg,
  allow_na = TRUE,
  arg_nm = rlang::caller_arg(arg),
  error_call = rlang::caller_env()
)

Arguments

arg

A symbol referring to an argument accepting strings.

allow_na

Input boolean to determine if NA or NaN is allowed. Default: TRUE

arg_nm

Same as error_arg.

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

The TRUE or FALSE value supplied to arg.

Examples

# No error
input = TRUE
arg_match0_true_or_false(input)

# Allow NA
input = NA
arg_match0_true_or_false(input)

# Error as 0 is not TRUE or FALSE
input = 0
try(arg_match0_true_or_false(input))

# Error as 1 is not TRUE or FALSE
input = 1
try(arg_match0_true_or_false(input))

# Error as NULL is not TRUE or FALSE
input = NULL
try(arg_match0_true_or_false(input))

# Error as NA is not TRUE or FALSE and allow_na is FALSE
input = NA
try(arg_match0_true_or_false(input, allow_na = FALSE))

Calculate ACCF/AHA/ACP/AATS/PCNA/SCAI/STS 2012 PTP for obstructive CAD

Description

This function returns a patient's pre-test Probability (PTP) of obstructive coronary artery disease (CAD) based on the American College of Cardiology Foundation, American Heart Association, American College of Physicians, American Association for Thoracic Surgery, Preventive Cardiovascular Nurses Association, Society for Cardiovascular Angiography and Interventions, and Society of Thoracic Surgeons 2012 guidelines.

Usage

calculate_aha_2012_tbl_9_ptp(
  age,
  sex,
  chest_pain_type,
  output = c("numeric", "percentage"),
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN)
)

Arguments

age

Input integer value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

output

Input text to indicate the how pre-test probability results be expressed Default: c("numeric", "percentage")

  • numeric means the PTP will be expressed as an integer probability (0-100).

  • percentage means the PTP will be expressed as percentage text (0-100%).

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

Details

The predictive model used to create the guidelines are based on patients from the Diamond and Forrester and the Coronary Artery Surgery Study.

Value

An integer or percentage representing the patient's PTP for obstructive CAD based on the ACCF/AHA/ACP/AATS/PCNA/SCAI/STS 2012 guidelines.

Examples

# 35 year old female with typical chest pain
calculate_aha_2012_tbl_9_ptp(
    age = 35,
    sex = "female",
    chest_pain_type = "typical",
    output = "percentage"
)

# 65 year old male with nonanginal chest pain
calculate_aha_2012_tbl_9_ptp(
    age = 65,
    sex = "male",
    chest_pain_type = "nonanginal",
    output = "percentage"
)

Calculate AHA/ACC 2021 PTP for obstructive CAD

Description

This function returns a patient's pre-test Probability (PTP) of obstructive coronary artery disease (CAD) based on the American Heart Association/American College of Cardiology (AHA/ACC) 2021 guidelines.

Usage

calculate_aha_2021_ptp(
  age,
  sex,
  have_dyspnoea,
  have_chest_pain,
  output = c("grouping", "numeric", "percentage"),
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_have_dyspnoea_no = c("no"),
  label_have_dyspnoea_yes = c("yes"),
  label_have_dyspnoea_unknown = c(NA, NaN),
  label_have_chest_pain_no = c("no"),
  label_have_chest_pain_yes = c("yes"),
  label_have_chest_pain_unknown = c(NA, NaN)
)

Arguments

age

Input integer value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

have_dyspnoea

The value of variable in the parameters label_have_dyspnoea_no, label_have_dyspnoea_yes and label_have_dyspnoea_unknown.

have_chest_pain

The value of variable in the parameters label_have_chest_pain_no, label_have_chest_pain_yes and label_have_chest_pain_unknown.

output

Input text to indicate the how pre-test probability results be expressed Default: c("grouping", "numeric", "percentage")

  • grouping means the PTP will be expressed as Low, Intermediate and High.

    • very low if PTP is less than 5%.

    • low if PTP is in between 5% to 15%.

    • intermediate if PTP is in between 15% to 50%.

    • high if PTP is more than 50%.

  • numeric means the PTP will be expressed as an integer probability (0-100).

  • percentage means the PTP will be expressed as percentage text (0-100%).

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_have_dyspnoea_no

Label(s) for patient having no dyspnoea symptoms. Default: c("no")

label_have_dyspnoea_yes

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

label_have_dyspnoea_unknown

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

label_have_chest_pain_no

Label(s) for patient not having chest pain symptoms. Default: c("no")

label_have_chest_pain_yes

Label(s) for patient having chest pain symptoms. Default: c("yes")

label_have_chest_pain_unknown

Label(s) for patient with unknown chest pain symptoms. Default: c(NA, NaN)

Details

The predictive model used to create the guidelines are based on patients from European countries with low cardiovascular disease (CVD) risk.

If the patient has both dyspnoea and a particular chest pain type (typical, atypical, nonanginal), The chest pain type will take precedence over dyspnoea

Value

An integer, percentage or category representing the patient's PTP for obstructive CAD based on the AHA/ACC 2021 guidelines. See parameter option output for more information.

Examples

# 35 year old female with chest pain
calculate_aha_2021_ptp(
    age = 35,
    sex = "female",
    have_dyspnoea = "no",
    have_chest_pain = "yes",
    output = "percentage"
)

# 75 year old male with only dyspnoea
calculate_aha_2021_ptp(
    age = 75,
    sex = "male",
    have_dyspnoea = "yes",
    have_chest_pain = "no",
    output = "percentage"
)

Calculate 2011 CAD1 Basic PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2011 CAD Consortium 1 (CAD1) basic model.

Usage

calculate_cad1_2011_ptp(
  age,
  sex,
  chest_pain_type,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

Details

The predictive model is based on patients from 14 hospitals in Europe and the United States.

This model is also called the updated Diamond-Forrester model.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2011 CAD Consortium 1 (CAD1) basic model.

Examples

# 40 year old female with typical chest pain
calculate_cad1_2011_ptp(
    age = 40,
    sex = "female",
    chest_pain_type = "typical"
)

Calculate 2012 CAD2 Basic PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2012 CAD Consortium 2 (CAD2) basic model.

Usage

calculate_cad2_2012_basic_ptp(
  age,
  sex,
  chest_pain_type,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

Details

The predictive model is based on patients from 18 hospitals in Europe and the United States.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2012 CAD Consortium 2 (CAD2) basic model.

Examples

# 40 year old female with typical chest pain
calculate_cad2_2012_basic_ptp(
    age = 40,
    sex = "female",
    chest_pain_type = "typical"
)

Calculate 2012 CAD2 Clinical and CCS PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2012 CAD Consortium 2 (CAD2) clinical and coronary calcium score (CCS) model.

Usage

calculate_cad2_2012_clinical_ccs_ptp(
  age,
  sex,
  chest_pain_type,
  have_diabetes,
  have_hypertension,
  have_dyslipidemia,
  have_smoking_history,
  coronary_calcium_score,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_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_dyslipidemia_no = c("no"),
  label_have_dyslipidemia_yes = c("yes"),
  label_have_dyslipidemia_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)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_diabetes

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

have_hypertension

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

have_dyslipidemia

The value of variable in the parameters label_have_dyslipidemia_no, label_have_dyslipidemia_yes and label_have_dyslipidemia_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.

coronary_calcium_score

Input non-negative numeric to indicate the total coronary calcium score of the patient.

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. 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)

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_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_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)

Details

The predictive model is based on patients from 18 hospitals in Europe and the United States.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2012 CAD Consortium 2 (CAD2) clinical and coronary calcium score (CCS) model.

Examples

# 40 year old female with typical chest pain,
# diabetes but no hypertension, dyslipidemia,
# a non-smoker and a coronary calcium score of 0
calculate_cad2_2012_clinical_ccs_ptp(
    age = 40,
    sex = "female",
    chest_pain_type = "typical",
    have_diabetes = "yes",
    have_hypertension = "no",
    have_dyslipidemia = "no",
    have_smoking_history = "no",
    coronary_calcium_score = 0

)

Calculate 2012 CAD2 Clinical PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2012 CAD Consortium 2 (CAD2) clinical model.

Usage

calculate_cad2_2012_clinical_ptp(
  age,
  sex,
  chest_pain_type,
  have_diabetes,
  have_hypertension,
  have_dyslipidemia,
  have_smoking_history,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_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_dyslipidemia_no = c("no"),
  label_have_dyslipidemia_yes = c("yes"),
  label_have_dyslipidemia_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)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_diabetes

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

have_hypertension

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

have_dyslipidemia

The value of variable in the parameters label_have_dyslipidemia_no, label_have_dyslipidemia_yes and label_have_dyslipidemia_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.

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. 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)

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_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_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)

Details

The predictive model is based on patients from 18 hospitals in Europe and the United States.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2012 CAD Consortium 2 (CAD2) clinical model.

Examples

# 40 year old female with typical chest pain,
# diabetes but no hypertension, dyslipidemia
# and a non-smoker
calculate_cad2_2012_clinical_ptp(
    age = 40,
    sex = "female",
    chest_pain_type = "typical",
    have_diabetes = "yes",
    have_hypertension = "no",
    have_dyslipidemia = "no",
    have_smoking_history = "no"

)

Calculate Number Of Risk Factors (CONFIRM 2015)

Description

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 2015 CONFIRM Risk Score.

Usage

calculate_confirm_2015_num_of_rf(
  have_typical_chest_pain,
  have_diabetes,
  have_hypertension,
  have_family_history,
  is_current_smoker,
  max_na = 0,
  label_have_typical_chest_pain_no = c("no"),
  label_have_typical_chest_pain_yes = c("yes"),
  label_have_typical_chest_pain_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_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_family_history_no = c("no"),
  label_have_family_history_yes = c("yes"),
  label_have_family_history_unknown = c(NA, NaN),
  label_is_current_smoker_no = c("no"),
  label_is_current_smoker_yes = c("yes"),
  label_is_current_smoker_unknown = c(NA, NaN),
  error_call = rlang::caller_env()
)

Arguments

have_typical_chest_pain

The value of variable in the parameters label_have_typical_chest_pain_no, label_have_typical_chest_pain_yes and label_have_typical_chest_pain_unknown.

have_diabetes

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

have_hypertension

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

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.

is_current_smoker

The value of variable in the parameters label_is_current_smoker_no, label_is_current_smoker_yes and label_is_current_smoker_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_typical_chest_pain_no

Label(s) for patient not having typical chest pain symptom. Default: c("no")

label_have_typical_chest_pain_yes

Label(s) for patient having typical chest pain symptom. Default: c("yes")

label_have_typical_chest_pain_unknown

Label(s) for patient having unknown typical chest pain symptom.

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)

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_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_is_current_smoker_no

Label(s) for patients who are not current smokers. Default: c("no")

label_is_current_smoker_yes

Label(s) for patients who are current smokers. Default: c("yes")

label_is_current_smoker_unknown

Label(s) for patient with unknown smoking status.

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_confirm_2015_num_of_rf(
  have_typical_chest_pain = "yes",
  have_diabetes = "yes",
  have_hypertension = "yes",
  have_family_history = "yes",
  is_current_smoker = "no"
)

calculate_confirm_2015_num_of_rf(
  have_typical_chest_pain = "no",
  have_diabetes = "no",
  have_hypertension = "no",
  have_family_history = NA,
  is_current_smoker = "no",
  max_na = 0
)

calculate_confirm_2015_num_of_rf(
  have_typical_chest_pain = "no",
  have_diabetes = "no",
  have_hypertension = "no",
  have_family_history = NA,
  is_current_smoker = "no",
  max_na = 1
)

Calculate 2015 CONFIRM Risk Score for obstructive CAD

Description

This function returns a patient's risk score for obstructive coronary artery disease based on the 2015 CONFIRM Risk Score.

Usage

calculate_confirm_2015_ptp(
  age,
  sex,
  have_typical_chest_pain,
  have_diabetes,
  have_hypertension,
  have_family_history,
  is_current_smoker,
  max_na_num_of_rf = 0,
  output = c("text", "percentage"),
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_have_typical_chest_pain_no = c("no"),
  label_have_typical_chest_pain_yes = c("yes"),
  label_have_typical_chest_pain_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_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_family_history_no = c("no"),
  label_have_family_history_yes = c("yes"),
  label_have_family_history_unknown = c(NA, NaN),
  label_is_current_smoker_no = c("no"),
  label_is_current_smoker_yes = c("yes"),
  label_is_current_smoker_unknown = c(NA, NaN)
)

Arguments

age

Input integer value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

have_typical_chest_pain

The value of variable in the parameters label_have_typical_chest_pain_no, label_have_typical_chest_pain_yes and label_have_typical_chest_pain_unknown.

have_diabetes

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

have_hypertension

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

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.

is_current_smoker

The value of variable in the parameters label_is_current_smoker_no, label_is_current_smoker_yes and label_is_current_smoker_unknown.

max_na_num_of_rf

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

output

Input text to indicate the how pre-test probability results be expressed Default: c("text", "percentage")

  • text means the PTP will be expressed as a probability in text (0 to > 82.4).

  • percentage means the PTP will be expressed as percentage text (0-100%).

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_have_typical_chest_pain_no

Label(s) for patient not having typical chest pain symptom. Default: c("no")

label_have_typical_chest_pain_yes

Label(s) for patient having typical chest pain symptom. Default: c("yes")

label_have_typical_chest_pain_unknown

Label(s) for patient having unknown typical chest pain symptom.

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)

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_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_is_current_smoker_no

Label(s) for patients who are not current smokers. Default: c("no")

label_is_current_smoker_yes

Label(s) for patients who are current smokers. Default: c("yes")

label_is_current_smoker_unknown

Label(s) for patient with unknown smoking status.

Details

The predictive model is based on CCTA images from 9093 patients from Phase I of the Coronary CT Angiography EvaluatioN For Clinical Outcomes: An InteRnational Multicenter (CONFIRM) registry.

Value

A numeric value representing the patient's risk score for obstructive CAD based on the 2015 CONFIRM Risk Score.

Examples

# 30 years old male current smoker with typical chest pain
calculate_confirm_2015_ptp(
  age = 30,
  sex = "male",
  have_typical_chest_pain = "yes",
  have_diabetes = "no",
  have_hypertension = "no",
  have_family_history = "no",
  is_current_smoker = "yes",
  max_na_num_of_rf = 0,
  output = "percentage"
)

Calculate 1993 Duke Clinical Score for Left Main Disease

Description

This function returns a patient's pre-test probability (PTP) of severe (>75% luminal diameter narrowing of the left main coronary artery) coronary artery disease based on the 1993 Duke Clinical Score.

Usage

calculate_dcs_1993_lm_cad_ptp(
  age,
  sex,
  have_typical_chest_pain,
  have_peripheral_vascular_disease,
  have_cerebrovascular_disease,
  have_carotid_bruits,
  duration_of_cad_symptoms_year,
  max_na_vascular_disease_index = 0,
  max_age = 65,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_have_typical_chest_pain_no = c("no"),
  label_have_typical_chest_pain_yes = c("yes"),
  label_have_typical_chest_pain_unknown = c(NA, NaN),
  label_have_pvd_no = c("no"),
  label_have_pvd_yes = c("yes"),
  label_have_pvd_unknown = c(NA, NaN),
  label_have_cvd_no = c("no"),
  label_have_cvd_yes = c("yes"),
  label_have_cvd_unknown = c(NA, NaN),
  label_have_carotid_bruits_no = c("no"),
  label_have_carotid_bruits_yes = c("yes"),
  label_have_carotid_bruits_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

have_typical_chest_pain

The value of variable in the parameters label_have_typical_chest_pain_no, label_have_typical_chest_pain_yes and label_have_typical_chest_pain_unknown.

have_peripheral_vascular_disease

The value of variable in the parameters label_have_pvd_no, label_have_pvd_yes and label_have_pvd_unknown.

have_cerebrovascular_disease

The value of variable in the parameters label_have_cvd_no, label_have_cvd_yes and label_have_cvd_unknown.

have_carotid_bruits

The value of variable in the parameters label_have_carotid_bruits_no, label_have_carotid_bruits_yes and label_have_carotid_bruits_unknown.

duration_of_cad_symptoms_year

Input integer to indicate the duration of coronary artery disease symptoms in years.

max_na_vascular_disease_index

Input integer 0 to 3 to indicate the maximum number of missing disease history to tolerate before outputting an NA. Default: 0

max_age

Input positive integer to indicate the maximum age to tolerate before outputting an NA. In the Duke Clinical Score 1993 paper, the maximum value is set as 65. Default: 65

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_have_typical_chest_pain_no

Label(s) for patient not having typical chest pain symptom. Default: c("no")

label_have_typical_chest_pain_yes

Label(s) for patient having typical chest pain symptom. Default: c("yes")

label_have_typical_chest_pain_unknown

Label(s) for patient having unknown typical chest pain symptom.

label_have_pvd_no

Label(s) for patient not having peripheral vascular disease. Default: c("no")

label_have_pvd_yes

Label(s) for patient having peripheral vascular disease. Default: c("yes")

label_have_pvd_unknown

Label(s) for patient having unknown peripheral vascular disease. Default: c(NA, NaN)

label_have_cvd_no

Label(s) for patient not having cerebrovascular disease. Default: c("no")

label_have_cvd_yes

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

label_have_cvd_unknown

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

label_have_carotid_bruits_no

Label(s) for patient not having carotid bruits. Default: c("no")

label_have_carotid_bruits_yes

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

label_have_carotid_bruits_unknown

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

Details

The predictive model is based on patients referred for cardiac catheterisation between 1969 and 1983.

Value

A numeric value representing the patient's PTP for left main disease (>75% luminal diameter narrowing of the left main coronary artery) based on the 1993 Duke Clinical Score.

Examples

# 40 year old female with typical chest pain for one year,
# She has peripheral vascular and cerebrovascular disease.

calculate_dcs_1993_lm_cad_ptp(
    age = 40,
    sex = "female",
    have_typical_chest_pain = "yes",
    have_peripheral_vascular_disease = "yes",
    have_cerebrovascular_disease = "yes",
    have_carotid_bruits = "no",
    duration_of_cad_symptoms_year = 1,
)


Calculate The Pain Index For Duke Clinical Score 1993

Description

A function used to calculate the patient's pain index. This is used to calculate the likelihood of severe coronary artery disease in the Duke Clinical Score 1993 paper.

Usage

calculate_dcs_1993_pain_index(
  have_typical_chest_pain,
  frequency_of_angina_pain_per_week,
  have_progressive_angina,
  have_nocturnal_angina,
  have_q_waves,
  have_st_t_changes,
  max_na = 0,
  max_frequency_of_angina_pain_per_week = 35,
  label_have_typical_chest_pain_no = c("no"),
  label_have_typical_chest_pain_yes = c("yes"),
  label_have_typical_chest_pain_unknown = c(NA, NaN),
  label_have_progressive_angina_no = c("no"),
  label_have_progressive_angina_yes = c("yes"),
  label_have_progressive_angina_unknown = c(NA, NaN),
  label_have_nocturnal_angina_no = c("no"),
  label_have_nocturnal_angina_yes = c("yes"),
  label_have_nocturnal_angina_unknown = c(NA, NaN),
  label_have_q_waves_no = c("no"),
  label_have_q_waves_yes = c("yes"),
  label_have_q_waves_unknown = c(NA, NaN),
  label_have_st_t_changes_no = c("no"),
  label_have_st_t_changes_yes = c("yes"),
  label_have_st_t_changes_unknown = c(NA, NaN),
  error_call = rlang::caller_env()
)

Arguments

have_typical_chest_pain

The value of variable in the parameters label_have_typical_chest_pain_no, label_have_typical_chest_pain_yes and label_have_typical_chest_pain_unknown.

frequency_of_angina_pain_per_week

Input integer to indicate the patient's frequency of angina per week.

have_progressive_angina

The value of variable in the parameters label_have_progressive_angina_no, label_have_progressive_angina_yes and label_have_progressive_angina_unknown.

have_nocturnal_angina

The value of variable in the parameters label_have_nocturnal_angina_no, label_have_nocturnal_angina_yes and label_have_nocturnal_angina_unknown.

have_q_waves

The value of variable in the parameters label_have_q_waves_no, label_have_q_waves_yes and label_have_q_waves_unknown.

have_st_t_changes

The value of variable in the parameters label_have_st_t_changes_no, label_have_st_t_changes_yes and label_have_st_t_changes_unknown.

max_na

Input integer 0 to 6 to indicate the maximum number of missing symptoms to tolerate before outputting an NA. Default: 0

max_frequency_of_angina_pain_per_week

Input non-negative integer to indicate the maximum frequency angina per week to tolerate before outputting an NA. In the Duke Clinical Score 1993 paper, the maximum value is set as 35. Default: 35

label_have_typical_chest_pain_no

Label(s) for patient not having typical chest pain symptom. Default: c("no")

label_have_typical_chest_pain_yes

Label(s) for patient having typical chest pain symptom. Default: c("yes")

label_have_typical_chest_pain_unknown

Label(s) for patient having unknown typical chest pain symptom.

label_have_progressive_angina_no

Label(s) for patient not having progressive angina. Default: c("no")

label_have_progressive_angina_yes

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

label_have_progressive_angina_unknown

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

label_have_nocturnal_angina_no

Label(s) for patient not having nocturnal angina. Default: c("no")

label_have_nocturnal_angina_yes

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

label_have_nocturnal_angina_unknown

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

label_have_q_waves_no

Label(s) for patient not having Q waves on ECG. Default: c("no")

label_have_q_waves_yes

Label(s) for patient having Q waves on ECG. Default: c("yes")

label_have_q_waves_unknown

Label(s) for patient with unknown Q waves on ECG. Default: c(NA, NaN)

label_have_st_t_changes_no

Label(s) for patient not having ST-T changes on ECG. Default: c("no")

label_have_st_t_changes_yes

Label(s) for patient having ST-T changes on ECG. Default: c("yes")

label_have_st_t_changes_unknown

Label(s) for patient with unknown ST-T changes on ECG. 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 patient's pain index. It can also be NA if the number of missing symptoms exceeds the max_na input value or the frequency of angina per week exceed the max_frequency_of_angina_pain_per_week input value.

Examples

calculate_dcs_1993_pain_index(
  have_typical_chest_pain = "yes",
  frequency_of_angina_pain_per_week = 10,
  have_progressive_angina = "yes",
  have_nocturnal_angina = "no",
  have_q_waves = "no",
  have_st_t_changes = "no",
  max_na = 0,
  max_frequency_of_angina_pain_per_week = 35
)

calculate_dcs_1993_pain_index(
  have_typical_chest_pain = "yes",
  frequency_of_angina_pain_per_week = 10,
  have_progressive_angina = "yes",
  have_nocturnal_angina = NA,
  have_q_waves = "no",
  have_st_t_changes = "no",
  max_na = 0,
  max_frequency_of_angina_pain_per_week = 35
)

calculate_dcs_1993_pain_index(
  have_typical_chest_pain = "yes",
  frequency_of_angina_pain_per_week = 10,
  have_progressive_angina = "yes",
  have_nocturnal_angina = NA,
  have_q_waves = "no",
  have_st_t_changes = "no",
  max_na = 1,
  max_frequency_of_angina_pain_per_week = 35
)

calculate_dcs_1993_pain_index(
  have_typical_chest_pain = "yes",
  frequency_of_angina_pain_per_week = 40,
  have_progressive_angina = "yes",
  have_nocturnal_angina = "no",
  have_q_waves = "no",
  have_st_t_changes = "no",
  max_na = 0,
  max_frequency_of_angina_pain_per_week = 35
)

calculate_dcs_1993_pain_index(
  have_typical_chest_pain = "yes",
  frequency_of_angina_pain_per_week = 40,
  have_progressive_angina = "yes",
  have_nocturnal_angina = "no",
  have_q_waves = "no",
  have_st_t_changes = "no",
  max_na = 0,
  max_frequency_of_angina_pain_per_week = NA
)


Calculate The Risk Factor Index For Duke Clinical Score 1993

Description

A function used to calculate the patient's risk factor index. This is used to calculate the likelihood of severe coronary artery disease in the Duke Clinical Score 1993 paper.

Usage

calculate_dcs_1993_risk_factor_index(
  have_hypertension,
  have_dyslipidemia,
  have_diabetes,
  max_na = 0,
  label_have_hypertension_no = c("no"),
  label_have_hypertension_yes = c("yes"),
  label_have_hypertension_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_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_unknown = c(NA, NaN),
  error_call = rlang::caller_env()
)

Arguments

have_hypertension

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

have_dyslipidemia

The value of variable in the parameters label_have_dyslipidemia_no, label_have_dyslipidemia_yes and label_have_dyslipidemia_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 3 to indicate the maximum number of missing risk factors to tolerate before outputting an NA. Default: 0

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_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_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 patient's risk factor index. It can also be NA if the number of missing risk factors exceeds the max_na input value.

Examples

calculate_dcs_1993_risk_factor_index(
  have_hypertension = "yes",
  have_dyslipidemia = "yes",
  have_diabetes = "no"
)

calculate_dcs_1993_risk_factor_index(
  have_hypertension = NA,
  have_dyslipidemia = "yes",
  have_diabetes = "no",
  max_na = 0
)

calculate_dcs_1993_risk_factor_index(
  have_hypertension = NA,
  have_dyslipidemia = "yes",
  have_diabetes = "no",
  max_na = 1
)

Calculate 1993 Duke Clinical Score for Severe CAD

Description

This function returns a patient's pre-test probability (PTP) of severe (>75% luminal diameter narrowing of all three major coronary arteries or of the left main coronary artery) coronary artery disease based on the 1993 Duke Clinical Score.

Usage

calculate_dcs_1993_severe_cad_ptp(
  age,
  sex,
  chest_pain_type,
  have_progressive_angina,
  have_nocturnal_angina,
  have_peripheral_vascular_disease,
  have_cerebrovascular_disease,
  have_carotid_bruits,
  have_hypertension,
  have_dyslipidemia,
  have_diabetes,
  have_q_waves,
  have_st_t_changes,
  frequency_of_angina_pain_per_week,
  duration_of_cad_symptoms_year,
  max_na_risk_factor_index = 0,
  max_na_pain_index = 0,
  max_na_vascular_disease_index = 0,
  max_frequency_of_angina_pain_per_week = 35,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  label_have_progressive_angina_no = c("no"),
  label_have_progressive_angina_yes = c("yes"),
  label_have_progressive_angina_unknown = c(NA, NaN),
  label_have_nocturnal_angina_no = c("no"),
  label_have_nocturnal_angina_yes = c("yes"),
  label_have_nocturnal_angina_unknown = c(NA, NaN),
  label_have_pvd_no = c("no"),
  label_have_pvd_yes = c("yes"),
  label_have_pvd_unknown = c(NA, NaN),
  label_have_cvd_no = c("no"),
  label_have_cvd_yes = c("yes"),
  label_have_cvd_unknown = c(NA, NaN),
  label_have_carotid_bruits_no = c("no"),
  label_have_carotid_bruits_yes = c("yes"),
  label_have_carotid_bruits_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_dyslipidemia_no = c("no"),
  label_have_dyslipidemia_yes = c("yes"),
  label_have_dyslipidemia_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_unknown = c(NA, NaN),
  label_have_q_waves_no = c("no"),
  label_have_q_waves_yes = c("yes"),
  label_have_q_waves_unknown = c(NA, NaN),
  label_have_st_t_changes_no = c("no"),
  label_have_st_t_changes_yes = c("yes"),
  label_have_st_t_changes_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_progressive_angina

The value of variable in the parameters label_have_progressive_angina_no, label_have_progressive_angina_yes and label_have_progressive_angina_unknown.

have_nocturnal_angina

The value of variable in the parameters label_have_nocturnal_angina_no, label_have_nocturnal_angina_yes and label_have_nocturnal_angina_unknown.

have_peripheral_vascular_disease

The value of variable in the parameters label_have_pvd_no, label_have_pvd_yes and label_have_pvd_unknown.

have_cerebrovascular_disease

The value of variable in the parameters label_have_cvd_no, label_have_cvd_yes and label_have_cvd_unknown.

have_carotid_bruits

The value of variable in the parameters label_have_carotid_bruits_no, label_have_carotid_bruits_yes and label_have_carotid_bruits_unknown.

have_hypertension

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

have_dyslipidemia

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

have_diabetes

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

have_q_waves

The value of variable in the parameters label_have_q_waves_no, label_have_q_waves_yes and label_have_q_waves_unknown.

have_st_t_changes

The value of variable in the parameters label_have_st_t_changes_no, label_have_st_t_changes_yes and label_have_st_t_changes_unknown.

frequency_of_angina_pain_per_week

Input integer to indicate the patient's frequency of angina per week.

duration_of_cad_symptoms_year

Input integer to indicate the duration of coronary artery disease symptoms in years.

max_na_risk_factor_index

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

max_na_pain_index

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

max_na_vascular_disease_index

Input integer 0 to 3 to indicate the maximum number of missing disease history to tolerate before outputting an NA. Default: 0

max_frequency_of_angina_pain_per_week

Input non-negative integer to indicate the maximum frequency angina per week to tolerate before outputting an NA. In the Duke Clinical Score 1993 paper, the maximum value is set as 35. Default: 35

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

label_have_progressive_angina_no

Label(s) for patient not having progressive angina. Default: c("no")

label_have_progressive_angina_yes

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

label_have_progressive_angina_unknown

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

label_have_nocturnal_angina_no

Label(s) for patient not having nocturnal angina. Default: c("no")

label_have_nocturnal_angina_yes

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

label_have_nocturnal_angina_unknown

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

label_have_pvd_no

Label(s) for patient not having peripheral vascular disease. Default: c("no")

label_have_pvd_yes

Label(s) for patient having peripheral vascular disease. Default: c("yes")

label_have_pvd_unknown

Label(s) for patient having unknown peripheral vascular disease. Default: c(NA, NaN)

label_have_cvd_no

Label(s) for patient not having cerebrovascular disease. Default: c("no")

label_have_cvd_yes

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

label_have_cvd_unknown

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

label_have_carotid_bruits_no

Label(s) for patient not having carotid bruits. Default: c("no")

label_have_carotid_bruits_yes

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

label_have_carotid_bruits_unknown

Label(s) for patient having unknown carotid bruits. 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_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_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)

label_have_q_waves_no

Label(s) for patient not having Q waves on ECG. Default: c("no")

label_have_q_waves_yes

Label(s) for patient having Q waves on ECG. Default: c("yes")

label_have_q_waves_unknown

Label(s) for patient with unknown Q waves on ECG. Default: c(NA, NaN)

label_have_st_t_changes_no

Label(s) for patient not having ST-T changes on ECG. Default: c("no")

label_have_st_t_changes_yes

Label(s) for patient having ST-T changes on ECG. Default: c("yes")

label_have_st_t_changes_unknown

Label(s) for patient with unknown ST-T changes on ECG. Default: c(NA, NaN)

Details

The predictive model is based on patients referred for cardiac catheterisation between 1969 and 1983.

Value

A numeric value representing the patient's PTP for severe (>75% luminal diameter narrowing of all three major coronary arteries or of the left main coronary artery) CAD based on the 1993 Duke Clinical Score.

Examples

# 40 year old female with typical chest pain for one year,
# She has progressive angina but no nocturnal angina.
# Angina pain lasted at most five times a week.
# She has peripheral vascular and cerebrovascular disease.
# She has hypertension but has no dyslipidemia and not diabetic.
# She has Q waves and ST-T changes on ECG.

calculate_dcs_1993_severe_cad_ptp(
    age = 40,
    sex = "female",
    chest_pain_type = "typical",
    have_progressive_angina = "yes",
    have_nocturnal_angina = "no",
    have_peripheral_vascular_disease = "yes",
    have_cerebrovascular_disease = "yes",
    have_carotid_bruits = "no",
    have_hypertension = "yes",
    have_dyslipidemia = "no",
    have_diabetes = "no",
    have_q_waves = "yes",
    have_st_t_changes = "yes",
    frequency_of_angina_pain_per_week = 5,
    duration_of_cad_symptoms_year = 1,
)

Calculate 1993 Duke Clinical Score for Significant CAD

Description

This function returns a patient's pre-test probability (PTP) of significant (>75% luminal diameter narrowing of at least one major coronary artery) coronary artery disease based on the 1993 Duke Clinical Score.

Usage

calculate_dcs_1993_sig_cad_ptp(
  age,
  sex,
  chest_pain_type,
  have_mi,
  have_smoking_history,
  have_dyslipidemia,
  have_diabetes,
  have_q_waves,
  have_st_t_changes,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  label_have_mi_no = c("no"),
  label_have_mi_yes = c("yes"),
  label_have_mi_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_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_unknown = c(NA, NaN),
  label_have_q_waves_no = c("no"),
  label_have_q_waves_yes = c("yes"),
  label_have_q_waves_unknown = c(NA, NaN),
  label_have_st_t_changes_no = c("no"),
  label_have_st_t_changes_yes = c("yes"),
  label_have_st_t_changes_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_mi

The value of variable in the parameters label_have_mi_no, label_have_mi_yes and label_have_mi_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_diabetes

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

have_q_waves

The value of variable in the parameters label_have_q_waves_no, label_have_q_waves_yes and label_have_q_waves_unknown.

have_st_t_changes

The value of variable in the parameters label_have_st_t_changes_no, label_have_st_t_changes_yes and label_have_st_t_changes_unknown.

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

label_have_mi_no

Label(s) for patient not having a previous history of MI. Default: c("no")

label_have_mi_yes

Label(s) for patient having a previous history of MI. Default: c("yes")

label_have_mi_unknown

Label(s) for patient with unknown previous history of MI. 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_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)

label_have_q_waves_no

Label(s) for patient not having Q waves on ECG. Default: c("no")

label_have_q_waves_yes

Label(s) for patient having Q waves on ECG. Default: c("yes")

label_have_q_waves_unknown

Label(s) for patient with unknown Q waves on ECG. Default: c(NA, NaN)

label_have_st_t_changes_no

Label(s) for patient not having ST-T changes on ECG. Default: c("no")

label_have_st_t_changes_yes

Label(s) for patient having ST-T changes on ECG. Default: c("yes")

label_have_st_t_changes_unknown

Label(s) for patient with unknown ST-T changes on ECG. Default: c(NA, NaN)

Details

The predictive model is based on patients referred for cardiac catheterisation between 1969 and 1983.

Value

A numeric value representing the patient's PTP for significant (>75% luminal diameter narrowing of at least one major coronary artery) CAD based on the 1993 Duke Clinical Score.

Examples

# 40 year old female with typical chest pain,
# previous history of MI,
# has diabetes but no dyslipidemia and a non-smoker.
# She has Q waves but no ST-T changes on ECG.

calculate_dcs_1993_sig_cad_ptp(
    age = 40,
    sex = "female",
    chest_pain_type = "typical",
    have_mi = "yes",
    have_smoking_history = "no",
    have_dyslipidemia = "no",
    have_diabetes = "yes",
    have_q_waves = "yes",
    have_st_t_changes = "no"
)

Calculate The Vascular Disease Index For Duke Clinical Score 1993

Description

A function used to calculate the patient's vascular disease index. This is used to calculate the likelihood of severe coronary artery disease in the Duke Clinical Score 1993 paper.

Usage

calculate_dcs_1993_vascular_disease_index(
  have_peripheral_vascular_disease,
  have_cerebrovascular_disease,
  have_carotid_bruits,
  max_na = 0,
  label_have_pvd_no = c("no"),
  label_have_pvd_yes = c("yes"),
  label_have_pvd_unknown = c(NA, NaN),
  label_have_cvd_no = c("no"),
  label_have_cvd_yes = c("yes"),
  label_have_cvd_unknown = c(NA, NaN),
  label_have_carotid_bruits_no = c("no"),
  label_have_carotid_bruits_yes = c("yes"),
  label_have_carotid_bruits_unknown = c(NA, NaN),
  error_call = rlang::caller_env()
)

Arguments

have_peripheral_vascular_disease

The value of variable in the parameters label_have_pvd_no, label_have_pvd_yes and label_have_pvd_unknown.

have_cerebrovascular_disease

The value of variable in the parameters label_have_cvd_no, label_have_cvd_yes and label_have_cvd_unknown.

have_carotid_bruits

The value of variable in the parameters label_have_carotid_bruits_no, label_have_carotid_bruits_yes and label_have_carotid_bruits_unknown.

max_na

Input integer 0 to 3 to indicate the maximum number of missing disease history to tolerate before outputting an NA. Default: 0

label_have_pvd_no

Label(s) for patient not having peripheral vascular disease. Default: c("no")

label_have_pvd_yes

Label(s) for patient having peripheral vascular disease. Default: c("yes")

label_have_pvd_unknown

Label(s) for patient having unknown peripheral vascular disease. Default: c(NA, NaN)

label_have_cvd_no

Label(s) for patient not having cerebrovascular disease. Default: c("no")

label_have_cvd_yes

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

label_have_cvd_unknown

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

label_have_carotid_bruits_no

Label(s) for patient not having carotid bruits. Default: c("no")

label_have_carotid_bruits_yes

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

label_have_carotid_bruits_unknown

Label(s) for patient having unknown carotid bruits. 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 patient's vascular disease index. It can also be NA if the number of missing disease history exceeds the max_na input value.

Examples

calculate_dcs_1993_vascular_disease_index(
  have_peripheral_vascular_disease = "yes",
  have_cerebrovascular_disease = "yes",
  have_carotid_bruits = "no"
)

calculate_dcs_1993_vascular_disease_index(
  have_peripheral_vascular_disease = NA,
  have_cerebrovascular_disease = "yes",
  have_carotid_bruits = "no",
  max_na = 0
)

calculate_dcs_1993_vascular_disease_index(
  have_peripheral_vascular_disease = NA,
  have_cerebrovascular_disease = "yes",
  have_carotid_bruits = "no",
  max_na = 1
)

Calculate Diamond-Forrester 1979 PTP for obstructive CAD

Description

This function returns a patient's pre-test Probability (PTP) of obstructive coronary artery disease (CAD) based on Diamond-Forrester 1979 model.

Usage

calculate_diamond_forrester_1979_ptp(
  age,
  sex,
  chest_pain_type,
  output = c("numeric", "percentage"),
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN)
)

Arguments

age

Input integer value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

output

Input text to indicate the how pre-test probability results be expressed Default: c("numeric", "percentage")

  • numeric means the PTP will be expressed as an integer probability (0-100).

  • percentage means the PTP will be expressed as percentage text (0-100%).

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

Value

A numeric or percentage representing the patient's PTP for obstructive CAD based on Diamond-Forrester 1979 model.

Examples

# 35 year old female with typical chest pain
calculate_diamond_forrester_1979_ptp(
    age = 35,
    sex = "female",
    chest_pain_type = "typical",
    output = "percentage"
)

# 65 year old male with nonanginal chest pain
calculate_diamond_forrester_1979_ptp(
    age = 65,
    sex = "male",
    chest_pain_type = "nonanginal",
    output = "percentage"
)

Calculate ESC 2013 PTP for obstructive CAD

Description

This function returns a patient's pre-test Probability (PTP) of obstructive coronary artery disease (CAD) based on the European Society of Cardiology (ESC) 2013 guidelines.

Usage

calculate_esc_2013_ptp(
  age,
  sex,
  chest_pain_type,
  output = c("numeric", "percentage")
)

Arguments

age

Input integer value to indicate the age of the patient.

sex

Input characters (female, male) to indicate the sex of the patient.

  • female

  • male

chest_pain_type

Input characters (typical, atypical, nonanginal) to indicate the chest pain characteristics of the patient.

  • typical stands for the patient having typical chest pain.

  • atypical stands for the patient having atypical chest pain.

  • nonanginal stands for the patient having nonanginal or non-specific chest pain.

output

Input text to indicate the how pre-test probability results be expressed Default: c("numeric", "percentage")

  • numeric means the PTP will be expressed as an integer probability (0-100).

  • percentage means the PTP will be expressed as percentage text (0-100%).

Details

The predictive model used to create the guidelines are based on the journal A clinical prediction rule for the diagnosis of coronary artery disease: validation, updating, and extension by 2011 Genders et. al.

Value

An integer or percentage representing the patient's PTP for obstructive CAD based on the ESC 2013 guidelines.

Examples

# 35 year old female with typical chest pain
calculate_esc_2013_ptp(
    age = 35,
    sex = "female",
    chest_pain_type = "typical",
    output = "percentage"
)

# 65 year old male with nonanginal chest pain
calculate_esc_2013_ptp(
    age = 65,
    sex = "male",
    chest_pain_type = "nonanginal",
    output = "percentage"
)

Calculate ESC 2019 PTP for obstructive CAD

Description

This function returns a patient's pre-test Probability (PTP) of obstructive coronary artery disease (CAD) based on the European Society of Cardiology (ESC) 2019 guidelines.

Usage

calculate_esc_2019_ptp(
  age,
  sex,
  have_dyspnoea,
  chest_pain_type,
  output = c("grouping", "numeric", "percentage"),
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_have_dyspnoea_no = c("no"),
  label_have_dyspnoea_yes = c("yes"),
  label_have_dyspnoea_unknown = c(NA, NaN),
  label_cpt_no_chest_pain = c("no chest pain"),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN)
)

Arguments

age

Input integer value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

have_dyspnoea

The value of variable in the parameters label_have_dyspnoea_no, label_have_dyspnoea_yes and label_have_dyspnoea_unknown.

chest_pain_type

The value of variable in the parameters label_cpt_no_chest_pain, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

output

Input text to indicate the how pre-test probability results be expressed Default: c("grouping", "numeric", "percentage")

  • grouping means the PTP will be expressed as Low, Intermediate and High.

    • low if PTP is less than 5%.

    • intermediate if PTP is in between 5% to 15%.

    • high if PTP is more than 15%.

  • numeric means the PTP will be expressed as an integer probability (0-100).

  • percentage means the PTP will be expressed as percentage text (0-100%).

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_have_dyspnoea_no

Label(s) for patient having no dyspnoea symptoms. Default: c("no")

label_have_dyspnoea_yes

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

label_have_dyspnoea_unknown

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

label_cpt_no_chest_pain

Label(s) for patient having no chest pain. Default: c("no chest pain")

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

Details

The predictive model used to create the guidelines are based on patients from European countries with low cardiovascular disease (CVD) risk.

If the patient has both dyspnoea and a particular chest pain type (typical, atypical, nonanginal), The chest pain type will take precedence over dyspnoea.

Value

An integer, percentage or category representing the patient's PTP for obstructive CAD based on the ESC 2019 guidelines. See parameter option output for more information.

Examples

# 35 year old female with typical chest pain
calculate_esc_2019_ptp(
    age = 35,
    sex = "female",
    have_dyspnoea = "no",
    chest_pain_type = "typical",
    output = "percentage"
)

# 75 year old male with only dyspnoea
calculate_esc_2019_ptp(
    age = 75,
    sex = "male",
    have_dyspnoea = "yes",
    chest_pain_type = "no chest pain",
    output = "percentage"
)

Calculate ESC 2024 PTP for obstructive CAD

Description

This function returns a patient's pre-test Probability (PTP) of obstructive coronary artery disease (CAD) based on the European Society of Cardiology (ESC) 2024 guidelines.

Usage

calculate_esc_2024_fig_4_ptp(
  age,
  sex,
  chest_pain_type,
  have_dyspnoea,
  have_family_history,
  have_smoking_history,
  have_dyslipidemia,
  have_hypertension,
  have_diabetes,
  allow_na_symptom_score = TRUE,
  max_na_num_of_rf = 0,
  output = c("grouping", "numeric", "percentage"),
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_have_dyspnoea_no = c("no"),
  label_have_dyspnoea_yes = c("yes"),
  label_have_dyspnoea_unknown = c(NA, NaN),
  label_cpt_no_chest_pain = c("no chest pain"),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  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)
)

Arguments

age

Input integer value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters label_cpt_no_chest_pain, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_dyspnoea

The value of variable in the parameters label_have_dyspnoea_no, label_have_dyspnoea_yes and label_have_dyspnoea_unknown.

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.

allow_na_symptom_score

A logical evaluating to TRUE or FALSE indicating whether we can allow chest_pain_type or have_dyspnoea to be NA when calculating the score

max_na_num_of_rf

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

output

Input text to indicate the how pre-test probability results be expressed Default: c("grouping", "numeric", "percentage")

  • grouping means the PTP will be expressed as Low, Intermediate and High.

    • very low if PTP is less than or equal to 5%.

    • low if PTP is in between 6% to 15%.

    • moderate if PTP is more than 15%.

  • numeric means the PTP will be expressed as an integer probability (0-100).

  • percentage means the PTP will be expressed as percentage text (0-100%).

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_have_dyspnoea_no

Label(s) for patient having no dyspnoea symptoms. Default: c("no")

label_have_dyspnoea_yes

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

label_have_dyspnoea_unknown

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

label_cpt_no_chest_pain

Label(s) for patient having no chest pain. Default: c("no chest pain")

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

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)

Value

An integer, percentage or category representing the patient's PTP for obstructive CAD based on the ESC 2024 guidelines. See parameter option output for more information.

Examples

# 30 female with symptom score of 0 and 0 risk factors
calculate_esc_2024_fig_4_ptp(
  age = 30,
  sex = "female",
  chest_pain_type = "no chest pain",
  have_dyspnoea = "no",
  have_family_history = "no",
  have_smoking_history = "no",
  have_dyslipidemia = "no",
  have_hypertension = "no",
  have_diabetes = "no",
  allow_na_symptom_score = TRUE,
  max_na_num_of_rf = 0,
  output = "percentage"
)


Calculate ESC 2024 PTP for obstructive CAD

Description

This function returns a patient's pre-test Probability (PTP) of obstructive coronary artery disease (CAD) based on the European Society of Cardiology (ESC) 2024 guidelines.

Usage

calculate_esc_2024_fig_4_ptp_simplfied(
  age,
  sex,
  symptom_score,
  num_of_rf,
  output = c("grouping", "numeric", "percentage"),
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  error_call = rlang::caller_env()
)

Arguments

age

Input integer value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

symptom_score

An integer indicating the symptom score of the patient. This value can be calculated via the calculate_esc_2024_symptom_score

num_of_rf

An integer indicating the number of risk factors the patient has. This value can be calculated via the calculate_esc_2024_num_of_rf Risk factors are:

  • having a family history of CAD.

  • having a smoking history (current and past smoker).

  • having dyslipidemia.

  • having hypertension.

  • having diabetes.

output

Input text to indicate the how pre-test probability results be expressed Default: c("grouping", "numeric", "percentage")

  • grouping means the PTP will be expressed as Low, Intermediate and High.

    • very low if PTP is less than or equal to 5%.

    • low if PTP is in between 6% to 15%.

    • moderate if PTP is more than 15%.

  • numeric means the PTP will be expressed as an integer probability (0-100).

  • percentage means the PTP will be expressed as percentage text (0-100%).

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. 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, percentage or category representing the patient's PTP for obstructive CAD based on the ESC 2024 guidelines. See parameter option output for more information.

Examples

# 30 female with symptom score of 0 and 0 risk factors
calculate_esc_2024_fig_4_ptp_simplfied(
  age = 30,
  sex = "female",
  symptom_score = 0,
  num_of_rf = 0,
  output = "percentage"
)


Calculate Number Of Risk Factors (ESC 2024)

Description

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"
)

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
)

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
)

Calculate Symptom Score (ESC 2024)

Description

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

Usage

calculate_esc_2024_symptom_score(
  chest_pain_type,
  have_dyspnoea,
  allow_na = TRUE,
  label_have_dyspnoea_no = c("no"),
  label_have_dyspnoea_yes = c("yes"),
  label_have_dyspnoea_unknown = c(NA, NaN),
  label_cpt_no_chest_pain = c("no chest pain"),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  error_call = rlang::caller_env()
)

Arguments

chest_pain_type

The value of variable in the parameters label_cpt_no_chest_pain, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_dyspnoea

The value of variable in the parameters label_have_dyspnoea_no, label_have_dyspnoea_yes and label_have_dyspnoea_unknown.

allow_na

A logical evaluating to TRUE or FALSE indicating whether we can allow 'chest_pain_type' or 'have_dyspnoea' to be NA when calculating the score. Default: TRUE

label_have_dyspnoea_no

Label(s) for patient having no dyspnoea symptoms. Default: c("no")

label_have_dyspnoea_yes

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

label_have_dyspnoea_unknown

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

label_cpt_no_chest_pain

Label(s) for patient having no chest pain. Default: c("no chest pain")

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. 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 symptom score of the patient. It can also be NA if both chest_pain_type and have_dyspnoea are NA. Patients with both nonanginal chest pain and dyspnoea will be given a score of 2

Examples

calculate_esc_2024_symptom_score(
  chest_pain_type = "nonanginal",
  have_dyspnoea = "yes",
  allow_na = TRUE
)

calculate_esc_2024_symptom_score(
  chest_pain_type = "nonanginal",
  have_dyspnoea = NA,
  allow_na = FALSE
)

calculate_esc_2024_symptom_score(
  chest_pain_type = "nonanginal",
  have_dyspnoea = NA,
  allow_na = TRUE
)


Calculate 2022 LAH Clinical PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2022 Local Assessment of the Heart (LAH) clinical model.

Usage

calculate_lah_2022_clinical_ptp(
  age,
  sex,
  chest_pain_type,
  have_diabetes,
  have_hypertension,
  have_dyslipidemia,
  have_smoking_history,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_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_dyslipidemia_no = c("no"),
  label_have_dyslipidemia_yes = c("yes"),
  label_have_dyslipidemia_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)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_diabetes

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

have_hypertension

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

have_dyslipidemia

The value of variable in the parameters label_have_dyslipidemia_no, label_have_dyslipidemia_yes and label_have_dyslipidemia_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.

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. 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)

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_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_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)

Details

The predictive model is based on patients a mixed Asian cohort within Singapore with stable chest pain.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2022 Local Assessment of the Heart (LAH) clinical model.

Examples

# 40 year old female with typical chest pain,
# diabetes but no hypertension, dyslipidemia
# and a non-smoker
calculate_lah_2022_clinical_ptp(
    age = 40,
    sex = "female",
    chest_pain_type = "typical",
    have_diabetes = "yes",
    have_hypertension = "no",
    have_dyslipidemia = "no",
    have_smoking_history = "no"

)

Calculate 2022 LAH Extended PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2022 Local Assessment of the Heart (LAH) extended model.

Usage

calculate_lah_2022_extended_ptp(
  age,
  sex,
  chest_pain_type,
  have_diabetes,
  have_hypertension,
  have_dyslipidemia,
  have_smoking_history,
  coronary_calcium_score,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_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_dyslipidemia_no = c("no"),
  label_have_dyslipidemia_yes = c("yes"),
  label_have_dyslipidemia_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)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_diabetes

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

have_hypertension

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

have_dyslipidemia

The value of variable in the parameters label_have_dyslipidemia_no, label_have_dyslipidemia_yes and label_have_dyslipidemia_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.

coronary_calcium_score

Input non-negative numeric to indicate the total coronary calcium score of the patient.

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. 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)

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_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_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)

Details

The predictive model is based on patients a mixed Asian cohort within Singapore with stable chest pain.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2022 Local Assessment of the Heart (LAH) extended model.

Examples

# 40 year old female with typical chest pain,
# diabetes but no hypertension, dyslipidemia,
# a non-smoker and a coronary calcium score of 0
calculate_lah_2022_extended_ptp(
    age = 40,
    sex = "female",
    chest_pain_type = "typical",
    have_diabetes = "yes",
    have_hypertension = "no",
    have_dyslipidemia = "no",
    have_smoking_history = "no",
    coronary_calcium_score = 0

)

Calculate 2021 PRECISE Clinical PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2021 Predictive Risk scorE for CAD In Southeast Asians with chEst pain (PRECISE) clinical model.

Usage

calculate_precise_2021_clinical_ptp(
  age,
  sex,
  chest_pain_type,
  have_neck_radiation,
  have_diabetes,
  have_hypertension,
  smoking_history_type,
  have_q_waves,
  have_st_t_changes,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  label_have_neck_radiation_no = c("no"),
  label_have_neck_radiation_yes = c("yes"),
  label_have_neck_radiation_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_unknown = c(NA, NaN),
  label_have_hypertension_no = c("no"),
  label_have_hypertension_yes = c("yes"),
  label_have_hypertension_unknown = c(NA, NaN),
  label_smoking_history_type_current = c("current"),
  label_smoking_history_type_past = c("past"),
  label_smoking_history_type_none = c("none"),
  label_smoking_history_type_unknown = c(NA, NaN),
  label_have_q_waves_no = c("no"),
  label_have_q_waves_yes = c("yes"),
  label_have_q_waves_unknown = c(NA, NaN),
  label_have_st_t_changes_no = c("no"),
  label_have_st_t_changes_yes = c("yes"),
  label_have_st_t_changes_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_neck_radiation

The value of variable in the parameters label_have_neck_radiation_no, label_have_neck_radiation_yes and label_have_neck_radiation_unknown.

have_diabetes

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

have_hypertension

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

smoking_history_type

The value of variable in the parameters label_smoking_history_type_current, label_smoking_history_type_past, label_smoking_history_type_none and label_smoking_history_type_unknown

have_q_waves

The value of variable in the parameters label_have_q_waves_no, label_have_q_waves_yes and label_have_q_waves_unknown.

have_st_t_changes

The value of variable in the parameters label_have_st_t_changes_no, label_have_st_t_changes_yes and label_have_st_t_changes_unknown.

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

label_have_neck_radiation_no

Label(s) for patient without chest pain radiating to the neck. Default: c("no")

label_have_neck_radiation_yes

Label(s) for patient with chest pain radiating to the neck. Default: c("yes")

label_have_neck_radiation_unknown

Label(s) for patient with unknown chest pain radiating to the neck 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)

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_smoking_history_type_current

Label(s) for patient who is a current smoker. Default: c("current")

label_smoking_history_type_past

Label(s) for patient who is a past smoker. Default: c("past")

label_smoking_history_type_none

Label(s) for patient who is a non-smoker. Default: c("none")

label_smoking_history_type_unknown

Label(s) for patient with unknown smoking history. Default: c(NA, NaN)

label_have_q_waves_no

Label(s) for patient not having Q waves on ECG. Default: c("no")

label_have_q_waves_yes

Label(s) for patient having Q waves on ECG. Default: c("yes")

label_have_q_waves_unknown

Label(s) for patient with unknown Q waves on ECG. Default: c(NA, NaN)

label_have_st_t_changes_no

Label(s) for patient not having ST-T changes on ECG. Default: c("no")

label_have_st_t_changes_yes

Label(s) for patient having ST-T changes on ECG. Default: c("yes")

label_have_st_t_changes_unknown

Label(s) for patient with unknown ST-T changes on ECG. Default: c(NA, NaN)

Details

The predictive model is based on patients a mixed Asian cohort within Singapore with stable chest pain.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2021 Predictive Risk scorE for CAD In Southeast Asians with chEst pain (PRECISE) clinical model.

Examples

# 40 year old female with typical chest pain
# radiating to the neck, has diabetes
# but no hypertension and a non-smoker.
# She has Q waves but no ST-T changes on ECG.

calculate_precise_2021_clinical_ptp(
    age = 40,
    sex = "female",
    chest_pain_type = "typical",
    have_neck_radiation = "yes",
    have_diabetes = "yes",
    have_hypertension = "no",
    smoking_history_type = "none",
    have_q_waves = "yes",
    have_st_t_changes = "no"
)

Calculate 2021 PRECISE Simple PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2021 Predictive Risk scorE for CAD In Southeast Asians with chEst pain (PRECISE) simple model.

Usage

calculate_precise_2021_simple_ptp(
  age,
  sex,
  chest_pain_type,
  have_neck_radiation,
  have_diabetes,
  have_hypertension,
  smoking_history_type,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  label_have_neck_radiation_no = c("no"),
  label_have_neck_radiation_yes = c("yes"),
  label_have_neck_radiation_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_unknown = c(NA, NaN),
  label_have_hypertension_no = c("no"),
  label_have_hypertension_yes = c("yes"),
  label_have_hypertension_unknown = c(NA, NaN),
  label_smoking_history_type_current = c("current"),
  label_smoking_history_type_past = c("past"),
  label_smoking_history_type_none = c("none"),
  label_smoking_history_type_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_neck_radiation

The value of variable in the parameters label_have_neck_radiation_no, label_have_neck_radiation_yes and label_have_neck_radiation_unknown.

have_diabetes

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

have_hypertension

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

smoking_history_type

The value of variable in the parameters label_smoking_history_type_current, label_smoking_history_type_past, label_smoking_history_type_none and label_smoking_history_type_unknown

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

label_have_neck_radiation_no

Label(s) for patient without chest pain radiating to the neck. Default: c("no")

label_have_neck_radiation_yes

Label(s) for patient with chest pain radiating to the neck. Default: c("yes")

label_have_neck_radiation_unknown

Label(s) for patient with unknown chest pain radiating to the neck 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)

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_smoking_history_type_current

Label(s) for patient who is a current smoker. Default: c("current")

label_smoking_history_type_past

Label(s) for patient who is a past smoker. Default: c("past")

label_smoking_history_type_none

Label(s) for patient who is a non-smoker. Default: c("none")

label_smoking_history_type_unknown

Label(s) for patient with unknown smoking history. Default: c(NA, NaN)

Details

The predictive model is based on patients a mixed Asian cohort within Singapore with stable chest pain.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2021 Predictive Risk scorE for CAD In Southeast Asians with chEst pain (PRECISE) simple model.

Examples

# 40 year old female with typical chest pain
# radiating to the neck, has diabetes
# but no hypertension and a non-smoker

calculate_precise_2021_simple_ptp(
    age = 40,
    sex = "female",
    chest_pain_type = "typical",
    have_neck_radiation = "yes",
    have_diabetes = "yes",
    have_hypertension = "no",
    smoking_history_type = "none"

)

Calculate 2017 PROMISE Minimal-Risk Score for obstructive CAD

Description

This function returns a symptomatic (have chest pain or dyspnoea) patient's minimal risk score for obstructive coronary artery disease based on the 2017 PROMISE Minimal-Risk Score.

Usage

calculate_prms_2017_ptp(
  age,
  sex,
  hdl_mg_dl,
  is_minority_ethnicity,
  have_diabetes,
  have_hypertension,
  have_dyslipidemia,
  have_smoking_history,
  have_family_history,
  have_stress_symptoms = NA,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_is_minority_ethnicity_no = c("no"),
  label_is_minority_ethnicity_yes = c("yes"),
  label_is_minority_ethnicity_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_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_dyslipidemia_no = c("no"),
  label_have_dyslipidemia_yes = c("yes"),
  label_have_dyslipidemia_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_family_history_no = c("no"),
  label_have_family_history_yes = c("yes"),
  label_have_family_history_unknown = c(NA, NaN),
  label_have_stress_symptoms_no = c("no"),
  label_have_stress_symptoms_yes = c("yes"),
  label_have_stress_symptoms_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

hdl_mg_dl

Input positive numeric value to indicate the patient's high-density lipoprotein (HDL) in mg/dL.

is_minority_ethnicity

The value of variable in the parameters label_is_minority_ethnicity_no, label_is_minority_ethnicity_yes and label_is_minority_ethnicity_unknown.

have_diabetes

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

have_hypertension

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

have_dyslipidemia

The value of variable in the parameters label_have_dyslipidemia_no, label_have_dyslipidemia_yes and label_have_dyslipidemia_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_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_stress_symptoms

The value of variable in the parameters label_have_stress_symptoms_no, label_have_stress_symptoms_yes and label_have_stress_symptoms_unknown. Default: NA

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_is_minority_ethnicity_no

Label(s) for patient not from a racial or minority ethnicity (or patient is a non-Hispanic/Latino White). Default: c("no")

label_is_minority_ethnicity_yes

Label(s) for patient from a racial or minority ethnicity (or patient is not a non-Hispanic/Latino White). E.g. Blacks, Asians, etc. Default: c("yes")

label_is_minority_ethnicity_unknown

Label(s) for patient from an unknown ethnicity 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)

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_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_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_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_stress_symptoms_no

Label(s) for patient with no symptoms (negative results) related to physical or mental stress. Default: c("no")

label_have_stress_symptoms_yes

Label(s) for patient with symptoms (positive results) related to physical or mental stress. Default: c("yes")

label_have_stress_symptoms_unknown

Label(s) for patient with inconclusive results or patient has not taken any stress test Default: c(NA, NaN)

Details

The predictive model is based on CCTA images from 4632 patients in the Prospective Multicenter imaging Study for Evaluation of Chest Pain (PROMISE) trial.

Value

A numeric value representing the patient's minimal risk score for obstructive CAD based on the 2017 PROMISE Minimal-Risk Score.

Examples

# 50 year old white female with chest pain
# a medical history of hypertension, and a
# high-density lipoprotein cholesterol level of 70 mg/dL
calculate_prms_2017_ptp(
    age = 50,
    sex = "female",
    hdl_mg_dl = 70,
    is_minority_ethnicity = "no",
    have_diabetes = "no",
    have_hypertension = "yes",
    have_dyslipidemia = "no",
    have_smoking_history = "no",
    have_family_history = "no",
    have_stress_symptoms = "no"
)

# 40 year old non-white male with chest pain
# a medical history of diabetes, unknown stress symptoms and a
# high-density lipoprotein cholesterol level of 70 mg/dL
calculate_prms_2017_ptp(
    age = 40,
    sex = "male",
    hdl_mg_dl = 70,
    is_minority_ethnicity = "yes",
    have_diabetes = "yes",
    have_hypertension = "no",
    have_dyslipidemia = "no",
    have_smoking_history = "no",
    have_family_history = "no",
    have_stress_symptoms = NA
)

Calculate 2019 Reeh Basic PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2019 Reeh et. al. basic model.

Usage

calculate_reeh_2019_basic_ptp(
  age,
  sex,
  symptom_type,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_symptom_type_typical = c("typical"),
  label_symptom_type_atypical = c("atypical"),
  label_symptom_type_nonanginal = c("nonanginal"),
  label_symptom_type_dyspnoea = c("dyspnoea"),
  label_symptom_type_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

symptom_type

Input characters (typical, atypical, nonanginal, dyspnoea) to indicate the symptom characteristics of the patient.

  • typical stands for the patient having typical chest pain.

  • atypical stands for the patient having atypical chest pain.

  • nonanginal stands for the patient having nonanginal or non-specific chest pain.

  • dyspnoea stands for the patient having dyspnoea.

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_symptom_type_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_symptom_type_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_symptom_type_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_symptom_type_dyspnoea

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

label_symptom_type_unknown

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

Details

The predictive model is based on 3903 patients free of CAD and heart failure and suspected of angina, who were referred to a single, large, urban university hospital for assessment in 2012–15.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2019 Reeh et. al. basic model.

Examples

# 40 year old female with typical chest pain
calculate_reeh_2019_basic_ptp(
    age = 40,
    sex = "female",
    symptom_type = "typical"
)

Calculate 2019 Reeh Clinical PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2019 Reeh et. al. clinical model.

Usage

calculate_reeh_2019_clinical_ptp(
  age,
  sex,
  symptom_type,
  have_dyslipidemia,
  have_family_history,
  have_diabetes,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_symptom_type_typical = c("typical"),
  label_symptom_type_atypical = c("atypical"),
  label_symptom_type_nonanginal = c("nonanginal"),
  label_symptom_type_dyspnoea = c("dyspnoea"),
  label_symptom_type_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_family_history_no = c("no"),
  label_have_family_history_yes = c("yes"),
  label_have_family_history_unknown = c(NA, NaN),
  label_have_diabetes_no = c("no"),
  label_have_diabetes_yes = c("yes"),
  label_have_diabetes_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

symptom_type

Input characters (typical, atypical, nonanginal, dyspnoea) to indicate the symptom characteristics of the patient.

  • typical stands for the patient having typical chest pain.

  • atypical stands for the patient having atypical chest pain.

  • nonanginal stands for the patient having nonanginal or non-specific chest pain.

  • dyspnoea stands for the patient having dyspnoea.

have_dyslipidemia

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

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_diabetes

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

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_symptom_type_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_symptom_type_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_symptom_type_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_symptom_type_dyspnoea

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

label_symptom_type_unknown

Label(s) for patient having unknown symptoms. 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_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_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)

Details

The predictive model is based on 3903 patients free of CAD and heart failure and suspected of angina, who were referred to a single, large, urban university hospital for assessment in 2012–15.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2019 Reeh et. al. clinical model.

Examples

# 40 year old female with typical chest pain
calculate_reeh_2019_clinical_ptp(
    age = 40,
    sex = "female",
    symptom_type = "typical",
    have_dyslipidemia = "no",
    have_family_history = "no",
    have_diabetes = "no"
)

Calculate 2020 Winther Basic PTP for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2020 Winther et. al. basic model (Basic_PTP).

Usage

calculate_winther_2020_basic_ptp(
  age,
  sex,
  chest_pain_type,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_cpt_no_chest_pain = c("no chest pain"),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters label_cpt_no_chest_pain, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_cpt_no_chest_pain

Label(s) for patient having no chest pain. Default: c("no chest pain")

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

Details

The predictive model is based on > 40000 symptomatic patients from 2008 to 2017 from 13 hospitals in Western Denmark. These patients are registered under the Western Denmark Heart Registry.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2020 Winther et. al. basic model (Basic_PTP).

Examples

# 40 year old Male with typical chest pain
calculate_winther_2020_basic_ptp(
    age = 40,
    sex = "male",
    chest_pain_type = "typical"
)

# 40 year old Male with nonanginal chest pain
calculate_winther_2020_basic_ptp(
    age = 40,
    sex = "male",
    chest_pain_type = "nonanginal"
)

Calculate 2020 Winther CACS-CL PTP model for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on 2020 Winther et. al. Coronary Artery Calcium Score-Weighted Clinical Likelihood (CACS-CL) model.

Usage

calculate_winther_2020_cacs_cl_ptp(
  age,
  sex,
  chest_pain_type,
  have_dyspnoea,
  have_family_history,
  have_smoking_history,
  have_dyslipidemia,
  have_hypertension,
  have_diabetes,
  coronary_calcium_score,
  allow_na_symptom_score = TRUE,
  max_na_num_of_rf = 0,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_have_dyspnoea_no = c("no"),
  label_have_dyspnoea_yes = c("yes"),
  label_have_dyspnoea_unknown = c(NA, NaN),
  label_cpt_no_chest_pain = c("no chest pain"),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  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)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters label_cpt_no_chest_pain, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_dyspnoea

The value of variable in the parameters label_have_dyspnoea_no, label_have_dyspnoea_yes and label_have_dyspnoea_unknown.

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.

coronary_calcium_score

Input non-negative numeric to indicate the total coronary calcium score of the patient.

allow_na_symptom_score

A logical evaluating to TRUE or FALSE indicating whether we can allow chest_pain_type or have_dyspnoea to be NA when calculating the score

max_na_num_of_rf

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

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_have_dyspnoea_no

Label(s) for patient having no dyspnoea symptoms. Default: c("no")

label_have_dyspnoea_yes

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

label_have_dyspnoea_unknown

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

label_cpt_no_chest_pain

Label(s) for patient having no chest pain. Default: c("no chest pain")

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

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)

Details

The predictive model is based on > 40000 symptomatic patients from 2008 to 2017 from 13 hospitals in Western Denmark. These patients are registered under the Western Denmark Heart Registry.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2020 Winther et. al. Coronary Artery Calcium Score-Weighted Clinical Likelihood (CACS-CL) model.

Examples

# 40 year old Male with nonanginal chest pain and coronary calcium score of 0
calculate_winther_2020_cacs_cl_ptp(
    age = 40,
    sex = "male",
    chest_pain_type = "no chest pain",
    have_dyspnoea = "no",
    have_family_history = "no",
    have_smoking_history = "no",
    have_dyslipidemia = "no",
    have_hypertension = "no",
    have_diabetes = "no",
    coronary_calcium_score = 0,
    allow_na_symptom_score = TRUE,
    max_na_num_of_rf = 0
)

Calculate 2020 Winther RF-CL PTP model for obstructive CAD

Description

This function returns a patient's pre-test probability (PTP) of obstructive coronary artery disease based on the 2020 Winther et. al. Risk Factor-Weighted Clinical Likelihood (RF-CL) model.

Usage

calculate_winther_2020_rf_cl_ptp(
  age,
  sex,
  chest_pain_type,
  have_dyspnoea,
  have_family_history,
  have_smoking_history,
  have_dyslipidemia,
  have_hypertension,
  have_diabetes,
  allow_na_symptom_score = TRUE,
  max_na_num_of_rf = 0,
  label_sex_male = c("male"),
  label_sex_female = c("female"),
  label_sex_unknown = c(NA, NaN),
  label_have_dyspnoea_no = c("no"),
  label_have_dyspnoea_yes = c("yes"),
  label_have_dyspnoea_unknown = c(NA, NaN),
  label_cpt_no_chest_pain = c("no chest pain"),
  label_cpt_nonanginal = c("nonanginal"),
  label_cpt_atypical = c("atypical"),
  label_cpt_typical = c("typical"),
  label_cpt_unknown = c(NA, NaN),
  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)
)

Arguments

age

Input numeric value to indicate the age of the patient in years.

sex

The value of variable in the parameters label_sex_male, label_sex_female and label_sex_unknown.

chest_pain_type

The value of variable in the parameters label_cpt_no_chest_pain, label_cpt_nonanginal, label_cpt_atypical, label_cpt_typical and label_cpt_unknown.

have_dyspnoea

The value of variable in the parameters label_have_dyspnoea_no, label_have_dyspnoea_yes and label_have_dyspnoea_unknown.

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.

allow_na_symptom_score

A logical evaluating to TRUE or FALSE indicating whether we can allow chest_pain_type or have_dyspnoea to be NA when calculating the score

max_na_num_of_rf

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

label_sex_male

Label(s) for definition(s) of male sex. Default: c("male")

label_sex_female

Label(s) for definition(s) of female sex. Default: c("female")

label_sex_unknown

Label(s) for definition(s) of missing sex. Default: c(NA, NaN)

label_have_dyspnoea_no

Label(s) for patient having no dyspnoea symptoms. Default: c("no")

label_have_dyspnoea_yes

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

label_have_dyspnoea_unknown

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

label_cpt_no_chest_pain

Label(s) for patient having no chest pain. Default: c("no chest pain")

label_cpt_nonanginal

Label(s) for patient having nonanginal or non-specific chest pain. Default: c("nonanginal")

label_cpt_atypical

Label(s) for patient having atypical chest pain. Default: c("atypical")

label_cpt_typical

Label(s) for patient having typical chest pain. Default: c("typical")

label_cpt_unknown

Label(s) for patient having unknown chest pain type symptoms. Default: c(NA, NaN)

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)

Details

The predictive model is based on > 40000 symptomatic patients from 2008 to 2017 from 13 hospitals in Western Denmark. These patients are registered under the Western Denmark Heart Registry.

Value

A numeric value representing the patient's PTP for obstructive CAD based on the 2020 Winther et. al. Risk Factor-Weighted Clinical Likelihood (RF-CL) model.

Examples

# 40 year old Male with nonanginal chest pain
calculate_winther_2020_rf_cl_ptp(
    age = 40,
    sex = "male",
    chest_pain_type = "no chest pain",
    have_dyspnoea = "no",
    have_family_history = "no",
    have_smoking_history = "no",
    have_dyslipidemia = "no",
    have_hypertension = "no",
    have_diabetes = "no",
    allow_na_symptom_score = TRUE,
    max_na_num_of_rf = 0
)

Check If Four Categories Are Mutually Exclusive

Description

Check if the four input categories are mutually exclusive from each other

Usage

check_if_four_categories_are_mutually_exclusive(
  label_cat_1,
  label_cat_2,
  label_cat_3,
  label_cat_4,
  label_cat_missing = NULL,
  arg_cat_1 = rlang::caller_arg(label_cat_1),
  arg_cat_2 = rlang::caller_arg(label_cat_2),
  arg_cat_3 = rlang::caller_arg(label_cat_3),
  arg_cat_4 = rlang::caller_arg(label_cat_4),
  arg_cat_missing = rlang::caller_arg(label_cat_missing),
  error_call = rlang::caller_env()
)

Arguments

label_cat_1

First vector to check for mutually exclusiveness with another vector.

label_cat_2

Second vector to check for mutually exclusiveness with another vector.

label_cat_3

Third vector to check for mutually exclusiveness with another vector

label_cat_4

Fourth vector to check for mutually exclusiveness with another vector

label_cat_missing

Missing values vector to check for mutually exclusiveness with another vector if needed. Default: NULL

arg_cat_1

An argument name as a string for the first vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

arg_cat_2

An argument name as a string for the second vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

arg_cat_3

An argument name as a string for the third vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

arg_cat_4

An argument name as a string for the fourth vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

arg_cat_missing

An argument name as a string for the missing values vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

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 error message if the four input categories are not mutually exclusive

See Also

caller_arg, stack cli_vec, cli_abort

Examples

# No error
cat_1 <- c("no chest pain")
cat_2 <- c("typical")
cat_3 <- c("atypical")
cat_4 <- c("nonanginal")
cat_missing <- c("NA")
check_if_four_categories_are_mutually_exclusive(cat_1, cat_2, cat_3, cat_4)
check_if_four_categories_are_mutually_exclusive(cat_1, cat_2, cat_3, cat_4, cat_missing)

# Common labels found
cat_1 <- c("no chest pain","typical", "atypical", "nonanginal")
cat_2 <- c("no chest pain","typical", "atypical", "nonanginal")
cat_3 <- c("no chest pain","typical", "atypical", "nonanginal")
cat_4 <- c("no chest pain","typical", "atypical", "nonanginal")
cat_missing <- c("no chest pain","typical", "atypical", "nonanginal")

try(check_if_four_categories_are_mutually_exclusive(cat_1, cat_2, cat_3, cat_4))

try(check_if_four_categories_are_mutually_exclusive(cat_1, cat_2, cat_3, cat_4, cat_missing))

Check If Integer

Description

Check if the input variable is an integer

Usage

check_if_integer(
  x,
  allow_na = TRUE,
  arg = rlang::caller_arg(x),
  error_call = rlang::caller_env()
)

Arguments

x

Input variable to check if it is an integer

allow_na

Input boolean to determine if NA or NaN is allowed. Default: TRUE

arg

An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.

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

The variable itself or an error message if variable is not non-negative

See Also

caller_arg, stack cli_abort

Examples

# No error
input = 0
try(check_if_integer(input))

# Error as 5.5 is not an integer
input = 5.5
try(check_if_integer(input))

Check If Non-Negative

Description

Check if the input variable is a non-negative number

Usage

check_if_non_negative(
  x,
  allow_na = TRUE,
  arg = rlang::caller_arg(x),
  error_call = rlang::caller_env()
)

Arguments

x

Input variable to check if it is non-negative number

allow_na

Input boolean to determine if NA or NaN is allowed. Default: TRUE

arg

An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.

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

The variable itself or an error message if variable is not non-negative

See Also

caller_arg, stack cli_abort

Examples

# No error
input = 0
try(check_if_non_negative(input))

# Error as -5 is not a non-neagtive number
input = -5
try(check_if_non_negative(input))

Check If Numeric

Description

Check if the input variable is numeric

Usage

check_if_numeric(
  x,
  allow_na = TRUE,
  arg = rlang::caller_arg(x),
  error_call = rlang::caller_env()
)

Arguments

x

Input variable to check if it is numeric

allow_na

Input boolean to determine if NA or NaN is allowed. Default: TRUE

arg

An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.

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

The variable itself or an error message if variable is not numeric

See Also

caller_arg, stack cli_abort

Examples

# No error
input = 1
try(check_if_numeric(input))

# Error as "5" is not numeric
input = "5"
try(check_if_numeric(input))

# Error as NULL is not numeric
input = NULL
try(check_if_numeric(input))

# Error as NA is not numeric and allow_na is FALSE
input = NA
try(check_if_numeric(input, allow_na = FALSE))


Check If Positive

Description

Check if the input variable is a positive number

Usage

check_if_positive(
  x,
  allow_na = TRUE,
  arg = rlang::caller_arg(x),
  error_call = rlang::caller_env()
)

Arguments

x

Input variable to check if it is positive number

allow_na

Input boolean to determine if NA or NaN is allowed. Default: TRUE

arg

An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.

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

The variable itself or an error message if variable is not positive

See Also

caller_arg, stack cli_abort

Examples

# No error
input = 1
try(check_if_positive(input))

# Error as 0 is not a positive number
input = 0
try(check_if_positive(input))

# Error as -5 is not a positive number
input = -5
try(check_if_positive(input))

Check If Three Categories Are Mutually Exclusive

Description

Check if the three input categories are mutually exclusive from each other

Usage

check_if_three_categories_are_mutually_exclusive(
  label_cat_1,
  label_cat_2,
  label_cat_3,
  label_cat_missing = NULL,
  arg_cat_1 = rlang::caller_arg(label_cat_1),
  arg_cat_2 = rlang::caller_arg(label_cat_2),
  arg_cat_3 = rlang::caller_arg(label_cat_3),
  arg_cat_missing = rlang::caller_arg(label_cat_missing),
  error_call = rlang::caller_env()
)

Arguments

label_cat_1

First vector to check for mutually exclusiveness with another vector.

label_cat_2

Second vector to check for mutually exclusiveness with another vector.

label_cat_3

Third vector to check for mutually exclusiveness with another vector

label_cat_missing

Missing values vector to check for mutually exclusiveness with another vector if needed. Default: NULL

arg_cat_1

An argument name as a string for the first vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

arg_cat_2

An argument name as a string for the second vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

arg_cat_3

An argument name as a string for the third vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

arg_cat_missing

An argument name as a string for the missing values vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

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 error message if the three input categories are not mutually exclusive

See Also

caller_arg, stack cli_vec, cli_abort

Examples

# No error
cat_1 <- c("typical")
cat_2 <- c("atypical")
cat_3 <- c("nonanginal")
cat_missing <- c("NA")
check_if_three_categories_are_mutually_exclusive(cat_1, cat_2, cat_3)
check_if_three_categories_are_mutually_exclusive(cat_1, cat_2, cat_3, cat_missing)

# Common labels found
cat_1 <- c("typical", "atypical", "nonanginal", "NA")
cat_2 <- c("typical", "atypical", "nonanginal", "NA")
cat_3 <- c("typical", "atypical", "nonanginal", "NA")
cat_missing <- c("typical", "atypical", "nonanginal", "NA")

try(check_if_three_categories_are_mutually_exclusive(cat_1, cat_2, cat_3))

try(check_if_three_categories_are_mutually_exclusive(cat_1, cat_2, cat_3, cat_missing))

Check If Two Categories Are Mutually Exclusive

Description

Check if the two input categories are mutually exclusive from each other

Usage

check_if_two_categories_are_mutually_exclusive(
  label_cat_1,
  label_cat_2,
  label_cat_missing = NULL,
  arg_cat_1 = rlang::caller_arg(label_cat_1),
  arg_cat_2 = rlang::caller_arg(label_cat_2),
  arg_cat_missing = rlang::caller_arg(label_cat_missing),
  error_call = rlang::caller_env()
)

Arguments

label_cat_1

First vector to check for mutually exclusiveness with another vector.

label_cat_2

Second vector to check for mutually exclusiveness with another vector.

label_cat_missing

Missing values vector to check for mutually exclusiveness with another vector if needed. Default: NULL

arg_cat_1

An argument name as a string for the first vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

arg_cat_2

An argument name as a string for the second vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

arg_cat_missing

An argument name as a string for the missing values vector. This argument will be mentioned in error messages as the input that is at the origin of a problem.

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 error message if the two input categories are not mutually exclusive

See Also

caller_arg, stack cli_vec, cli_abort

Examples

# No error
cat_1 <- c("male")
cat_2 <- c("female")
cat_missing <- c("not saying")
check_if_two_categories_are_mutually_exclusive(cat_1, cat_2)
check_if_two_categories_are_mutually_exclusive(cat_1, cat_2, cat_missing)

# Common labels found
cat_1 <- c("male", "female", "not saying")
cat_2 <- c("male", "female", "not saying")
cat_missing <- c("male", "female", "not saying")

try(check_if_two_categories_are_mutually_exclusive(cat_1, cat_2))

try(check_if_two_categories_are_mutually_exclusive(cat_1, cat_2, cat_missing))

Quoted Characters

Description

Add a quote around characters.

Usage

chr_quoted(chr, type = "`")

Arguments

chr

A character vector to add quotes in each element. (e.g. c("a", "b", "c")).

type

Character to be used as a quote. Default: '''

Details

DETAILS

Value

A character vector with quotes added in each element. (e.g. c("'a'", "'b'", "'c'")).

Examples

chr_quoted(c("a","b", "c"))

Harmonise Four Labels

Description

Function to map an input from four different list into one of the four standardise labels

Usage

harmonise_four_labels(
  arg,
  label_one,
  label_two,
  label_three,
  label_four,
  label_unknown,
  harmonise_label_one = "group_1",
  harmonise_label_two = "group_2",
  harmonise_label_three = "group_3",
  harmonise_label_four = "group_4",
  harmonise_label_unknown = NA,
  error_call = rlang::caller_env()
)

Arguments

arg

Input argument, in characters to be harmonised

label_one

Input character vector representing the ways to identify harmonise_label_one

label_two

Input character vector representing the ways to identify harmonise_label_two

label_three

Input character vector representing the ways to identify harmonise_label_three

label_four

Input character vector representing the ways to identify harmonise_label_four

label_unknown

Input character vector representing the ways to identify harmonise_label_unknown

harmonise_label_one

Input character representing the harmonised label for label_one Default: 'group_1'

harmonise_label_two

Input character representing the harmonised label for label_two Default: 'group_2'

harmonise_label_three

Input character representing the harmonised label for label_three Default: 'group_3'

harmonise_label_four

Input character representing the harmonised label for label_four Default: 'group_4'

harmonise_label_unknown

Input character representing the harmonised label for label_unknown Default: NA

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

Character representing one of the four standardise labels.

Examples

label_cpt_no_chest_pain <- c("no chest pain", "normal")
label_cpt_nonanginal <- c("nonanginal", "unspecified")
label_cpt_atypical <- c("atypical", "Atypical")
label_cpt_typical <- c("typical", "angina")
label_cpt_unknown <- c(NA, NaN)

# Gives harmonise_label_one if there is valid input of chest_pain_type
chest_pain_type <- "normal"

harmonise_four_labels(
   arg = chest_pain_type,
   label_one = label_cpt_no_chest_pain,
   label_two = label_cpt_nonanginal,
   label_three = label_cpt_atypical,
   label_four = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "no chest pain",
   harmonise_label_two = "nonanginal",
   harmonise_label_three = "atypical",
   harmonise_label_four = "typical",
   harmonise_label_unknown = NA
)

# Gives harmonise_label_two if there is valid input of chest_pain_type
chest_pain_type <- "unspecified"

harmonise_four_labels(
   arg = chest_pain_type,
   label_one = label_cpt_no_chest_pain,
   label_two = label_cpt_nonanginal,
   label_three = label_cpt_atypical,
   label_four = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "no chest pain",
   harmonise_label_two = "nonanginal",
   harmonise_label_three = "atypical",
   harmonise_label_four = "typical",
   harmonise_label_unknown = NA
)

# Gives harmonise_label_three if there is valid input of chest_pain_type
chest_pain_type <- "Atypical"

harmonise_four_labels(
   arg = chest_pain_type,
   label_one = label_cpt_no_chest_pain,
   label_two = label_cpt_nonanginal,
   label_three = label_cpt_atypical,
   label_four = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "no chest pain",
   harmonise_label_two = "nonanginal",
   harmonise_label_three = "atypical",
   harmonise_label_four = "typical",
   harmonise_label_unknown = NA
)

# Gives harmonise_label_four if there is valid input of chest_pain_type
chest_pain_type <- "angina"

harmonise_four_labels(
   arg = chest_pain_type,
   label_one = label_cpt_no_chest_pain,
   label_two = label_cpt_nonanginal,
   label_three = label_cpt_atypical,
   label_four = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "no chest pain",
   harmonise_label_two = "nonanginal",
   harmonise_label_three = "atypical",
   harmonise_label_four = "typical",
   harmonise_label_unknown = NA
)

# Gives harmonise_label_unknown if there is valid missing input of chest_pain_type
chest_pain_type <- NaN

harmonise_four_labels(
   arg = chest_pain_type,
   label_one = label_cpt_no_chest_pain,
   label_two = label_cpt_nonanginal,
   label_three = label_cpt_atypical,
   label_four = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "no chest pain",
   harmonise_label_two = "nonanginal",
   harmonise_label_three = "atypical",
   harmonise_label_four = "typical",
   harmonise_label_unknown = NA
)

# Gives harmonise_label_unknown if there is valid missing input of chest_pain_type
chest_pain_type <- "NIL"
label_cpt_unknown <- c("NIL")

harmonise_four_labels(
   arg = chest_pain_type,
   label_one = label_cpt_no_chest_pain,
   label_two = label_cpt_nonanginal,
   label_three = label_cpt_atypical,
   label_four = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "no chest pain",
   harmonise_label_two = "nonanginal",
   harmonise_label_three = "atypical",
   harmonise_label_four = "typical",
   harmonise_label_unknown = NA
)

# Gives error of invalid typical chest pain input with partial match
chest_pain_type <- "Typical"
label_cpt_unknown <- c(NA, NaN)

try(harmonise_four_labels(
   arg = chest_pain_type,
   label_one = label_cpt_no_chest_pain,
   label_two = label_cpt_nonanginal,
   label_three = label_cpt_atypical,
   label_four = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "no chest pain",
   harmonise_label_two = "nonanginal",
   harmonise_label_three = "atypical",
   harmonise_label_four = "typical",
   harmonise_label_unknown = NA
))

# Gives error of invalid typical chest pain input without partial match
chest_pain_type <- "Something"
label_cpt_unknown <- c(NA, NaN)

try(harmonise_four_labels(
   arg = chest_pain_type,
   label_one = label_cpt_no_chest_pain,
   label_two = label_cpt_nonanginal,
   label_three = label_cpt_atypical,
   label_four = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "no chest pain",
   harmonise_label_two = "nonanginal",
   harmonise_label_three = "atypical",
   harmonise_label_four = "typical",
   harmonise_label_unknown = NA
))

# Gives error of invalid missing input of chest_pain_type
chest_pain_type <- NA
label_cpt_unknown <- c("NIL")

try(harmonise_four_labels(
   arg = chest_pain_type,
   label_one = label_cpt_no_chest_pain,
   label_two = label_cpt_nonanginal,
   label_three = label_cpt_atypical,
   label_four = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "no chest pain",
   harmonise_label_two = "nonanginal",
   harmonise_label_three = "atypical",
   harmonise_label_four = "typical",
   harmonise_label_unknown = NA
))



Harmonise Three Labels

Description

Function to map an input from three different list into one of the three standardise labels

Usage

harmonise_three_labels(
  arg,
  label_one,
  label_two,
  label_three,
  label_unknown,
  harmonise_label_one = "group_1",
  harmonise_label_two = "group_2",
  harmonise_label_three = "group_3",
  harmonise_label_unknown = NA,
  error_call = rlang::caller_env()
)

Arguments

arg

Input argument, in characters to be harmonised

label_one

Input character vector representing the ways to identify harmonise_label_one

label_two

Input character vector representing the ways to identify harmonise_label_two

label_three

Input character vector representing the ways to identify harmonise_label_three

label_unknown

Input character vector representing the ways to identify harmonise_label_unknown

harmonise_label_one

Input character representing the harmonised label for label_one Default: 'group_1'

harmonise_label_two

Input character representing the harmonised label for label_two Default: 'group_2'

harmonise_label_three

Input character representing the harmonised label for label_three Default: 'group_3'

harmonise_label_unknown

Input character representing the harmonised label for label_unknown Default: NA

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

Character representing one of the three standardise labels.

Examples

label_cpt_nonanginal <- c("nonanginal", "unspecified")
label_cpt_atypical <- c("atypical", "Atypical")
label_cpt_typical <- c("typical", "angina")
label_cpt_unknown <- c(NA, NaN)

# Gives harmonise_label_one if there is valid input of chest_pain_type
chest_pain_type <- "unspecified"

harmonise_three_labels(
   arg = chest_pain_type,
   label_one = label_cpt_nonanginal,
   label_two = label_cpt_atypical,
   label_three = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "nonanginal",
   harmonise_label_two = "atypical",
   harmonise_label_three = "typical",
   harmonise_label_unknown = NA
)

# Gives harmonise_label_two if there is valid input of chest_pain_type
chest_pain_type <- "Atypical"

harmonise_three_labels(
   arg = chest_pain_type,
   label_one = label_cpt_nonanginal,
   label_two = label_cpt_atypical,
   label_three = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "nonanginal",
   harmonise_label_two = "atypical",
   harmonise_label_three = "typical",
   harmonise_label_unknown = NA
)

# Gives harmonise_label_three if there is valid input of chest_pain_type
chest_pain_type <- "angina"

harmonise_three_labels(
   arg = chest_pain_type,
   label_one = label_cpt_nonanginal,
   label_two = label_cpt_atypical,
   label_three = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "nonanginal",
   harmonise_label_two = "atypical",
   harmonise_label_three = "typical",
   harmonise_label_unknown = NA
)

# Gives harmonise_label_unknown if there is valid missing input of chest_pain_type
chest_pain_type <- NaN

harmonise_three_labels(
   arg = chest_pain_type,
   label_one = label_cpt_nonanginal,
   label_two = label_cpt_atypical,
   label_three = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "nonanginal",
   harmonise_label_two = "atypical",
   harmonise_label_three = "typical",
   harmonise_label_unknown = NA
)

# Gives harmonise_label_unknown if there is valid missing input of chest_pain_type
chest_pain_type <- "NIL"
label_cpt_unknown <- c("NIL")

harmonise_three_labels(
   arg = chest_pain_type,
   label_one = label_cpt_nonanginal,
   label_two = label_cpt_atypical,
   label_three = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "nonanginal",
   harmonise_label_two = "atypical",
   harmonise_label_three = "typical",
   harmonise_label_unknown = NA
)

# Gives error of invalid typical chest pain input with partial match
chest_pain_type <- "Typical"
label_cpt_unknown <- c(NA, NaN)

try(harmonise_three_labels(
   arg = chest_pain_type,
   label_one = label_cpt_nonanginal,
   label_two = label_cpt_atypical,
   label_three = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "nonanginal",
   harmonise_label_two = "atypical",
   harmonise_label_three = "typical",
   harmonise_label_unknown = NA
))

# Gives error of invalid typical chest pain input without partial match
chest_pain_type <- "Something"
label_cpt_unknown <- c(NA, NaN)

try(harmonise_three_labels(
   arg = chest_pain_type,
   label_one = label_cpt_nonanginal,
   label_two = label_cpt_atypical,
   label_three = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "nonanginal",
   harmonise_label_two = "atypical",
   harmonise_label_three = "typical",
   harmonise_label_unknown = NA
))

# Gives error of invalid missing input of chest_pain_type
chest_pain_type <- NA
label_cpt_unknown <- c("NIL")

try(harmonise_three_labels(
   arg = chest_pain_type,
   label_one = label_cpt_nonanginal,
   label_two = label_cpt_atypical,
   label_three = label_cpt_typical,
   label_unknown = label_cpt_unknown,
   harmonise_label_one = "nonanginal",
   harmonise_label_two = "atypical",
   harmonise_label_three = "typical",
   harmonise_label_unknown = NA
))



Harmonise Two Labels

Description

Function to map an input from two different list into one of the two standardise labels

Usage

harmonise_two_labels(
  arg,
  label_one,
  label_two,
  label_unknown,
  harmonise_label_one = "no",
  harmonise_label_two = "yes",
  harmonise_label_unknown = NA,
  error_call = rlang::caller_env()
)

Arguments

arg

Input argument, in characters to be harmonised

label_one

Input character vector representing the ways to identify harmonise_label_one

label_two

Input character vector representing the ways to identify harmonise_label_two

label_unknown

Input character vector representing the ways to identify harmonise_label_unknown

harmonise_label_one

Input character representing the harmonised label for label_one Default: 'group_1'

harmonise_label_two

Input character representing the harmonised label for label_two Default: 'group_2'

harmonise_label_unknown

Input character representing the harmonised label for label_unknown Default: NA

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

Character representing one of the two standardise labels.

Examples

label_have_dyspnoea_no <- c("no", "No")
label_have_dyspnoea_yes <- c("yes", "Yes")
label_have_dyspnoea_unknown <- c(NA, NaN)

# Gives harmonise_label_one if there is valid input of have_dyspnoea
have_dyspnoea <- "No"

harmonise_two_labels(
  arg = have_dyspnoea,
  label_one = label_have_dyspnoea_no,
  label_two = label_have_dyspnoea_yes,
  label_unknown = label_have_dyspnoea_unknown,
  harmonise_label_one = "no",
  harmonise_label_two = "yes",
  harmonise_label_unknown = NA
)

# Gives harmonise_label_two if there is valid input of have_dyspnoea
have_dyspnoea <- "Yes"

harmonise_two_labels(
  arg = have_dyspnoea,
  label_one = label_have_dyspnoea_no,
  label_two = label_have_dyspnoea_yes,
  label_unknown = label_have_dyspnoea_unknown,
  harmonise_label_one = "no",
  harmonise_label_two = "yes",
  harmonise_label_unknown = NA
)

# Gives harmonise_label_unknown if there is valid missing input of have_dyspnoea
have_dyspnoea <- NaN

harmonise_two_labels(
  arg = have_dyspnoea,
  label_one = label_have_dyspnoea_no,
  label_two = label_have_dyspnoea_yes,
  label_unknown = label_have_dyspnoea_unknown,
  harmonise_label_one = "no",
  harmonise_label_two = "yes",
  harmonise_label_unknown = NA
)

# Gives harmonise_label_unknown if there is valid missing input of have_dyspnoea
have_dyspnoea <- "NIL"
label_have_dyspnoea_unknown <- c("NIL")

harmonise_two_labels(
  arg = have_dyspnoea,
  label_one = label_have_dyspnoea_no,
  label_two = label_have_dyspnoea_yes,
  label_unknown = label_have_dyspnoea_unknown,
  harmonise_label_one = "no",
  harmonise_label_two = "yes",
  harmonise_label_unknown = NA
)

# Gives error of invalid have_dyspnoea input with partial match
have_dyspnoea <- "Not"
label_have_dyspnoea_unknown <- c(NA, NaN)

try(harmonise_two_labels(
   arg = have_dyspnoea,
   label_one = label_have_dyspnoea_no,
   label_two = label_have_dyspnoea_yes,
   label_unknown = label_have_dyspnoea_unknown,
   harmonise_label_one = "no",
   harmonise_label_two = "yes",
   harmonise_label_unknown = NA
))

# Gives error of invalid have_dyspnoea input without partial match
have_dyspnoea <- "Something"
label_have_dyspnoea_unknown <- c(NA, NaN)

try(harmonise_two_labels(
   arg = have_dyspnoea,
   label_one = label_have_dyspnoea_no,
   label_two = label_have_dyspnoea_yes,
   label_unknown = label_have_dyspnoea_unknown,
   harmonise_label_one = "no",
   harmonise_label_two = "yes",
   harmonise_label_unknown = NA
))

# Gives error of invalid missing input of have_dyspnoea
have_dyspnoea <- NA
label_have_dyspnoea_unknown <- c("NIL")

try(harmonise_two_labels(
   arg = have_dyspnoea,
   label_one = label_have_dyspnoea_no,
   label_two = label_have_dyspnoea_yes,
   label_unknown = label_have_dyspnoea_unknown,
   harmonise_label_one = "no",
   harmonise_label_two = "yes",
   harmonise_label_unknown = NA
))



Is Integer Value

Description

Function to check if the input value is an integer.

Usage

is_integer_value(input_value, allow_na = FALSE)

Arguments

input_value

The input value

allow_na

If true, NA values are ignored and output is considered TRUE. Default: FALSE

Value

A boolean indicating TRUE when the input value is an integer and FALSE otherwise.

Examples


# An integer
is_integer_value(1)

# Not an integer
is_integer_value(1.1)

# Not numeric
is_integer_value("1")

# NA cases
is_integer_value(NA, allow_na = FALSE)
is_integer_value(NA, allow_na = TRUE)


Character Vector To List Phrase With Oxford Comma

Description

A function that converts a character vector into a list phrase that uses the Oxford comma.

Usage

oxford_comma(chr, sep = ", ", final = "or")

Arguments

chr

A character vector to turn into a list phrase (e.g. c("a", "b", "c")).

sep

Separator symbols used to separate the elements in the character vector, Default: ', '

final

String to use in place of the final separator when we have at least two elements in the character vector, Default: 'or'.

Value

A string in the form of a list that has a comma if there are at least three elements in the list (e.g. "a, b, or c")

Examples

oxford_comma(c("James", "John", "Jeremy"))

oxford_comma(c("James", "John", "Jeremy"), final = "and")

oxford_comma(c("James", "John"))

oxford_comma(c("James"))

Round To Nearest Digit

Description

A function that does symmetric rounding to the nearest digits.

Usage

round_to_nearest_digit(number, digits = 0)

Arguments

number

Input numeric value

digits

Input integer indicating the number of decimal places to be used. By default, it rounds off to the nearest integer. Default: 0

Value

A numeric value rounded off to a number of decimal places specified in the input digits.

Examples

round_to_nearest_digit(0.5)
round_to_nearest_digit(1.5)
round_to_nearest_digit(-0.5)
round_to_nearest_digit(-1.5)
round_to_nearest_digit(1021.125, digits = 2)