cvd_risk: Calculate risk of cardiovascular disease

View source: R/cvd_risk.R

cvd_riskR Documentation

Calculate risk of cardiovascular disease

Description

Calculate risk of cardiovascular disease

Usage

cvd_risk(
  x = NULL,
  method = "D'Agostino_2008",
  sex,
  age,
  total_cholesterol,
  hdl,
  systolic,
  bp_treated,
  diabetes,
  smoker,
  points = TRUE,
  ...
)

## Default S3 method:
cvd_risk(
  x = NULL,
  method = "D'Agostino_2008",
  sex,
  age,
  total_cholesterol,
  hdl,
  systolic,
  bp_treated,
  diabetes,
  smoker,
  points = TRUE,
  ...
)

## S3 method for class 'data.frame'
cvd_risk(
  x = NULL,
  method = "D'Agostino_2008",
  sex,
  age,
  total_cholesterol,
  hdl,
  systolic,
  bp_treated,
  diabetes,
  smoker,
  points = TRUE,
  combine = TRUE,
  ...
)

Arguments

x

optional data frame. If provided, the other arguments will be taken as column names under the assumption that each row represents a separate person, and each column provides one of the requested pieces of information

method

character. Currently only method = "D'Agostino_2008" is supported.

sex

character scalar indicating either sex for one person (i.e., male or female), or a column name in x containing sex values for multiple people

age

either a numeric scalar indicating age for one person, or a character scalar indicating the name of the column in x that contains age information. Units are years

total_cholesterol

same as age, but for total cholesterol, in mg/dL

hdl

same as age, but for HDL, in mg/dL

systolic

same as age, but for systolic blood pressure, in mmHg

bp_treated

either a logical scalar indicating whether a person is taking blood pressure medication, or a character scalar pointing to the column in x that contains the same information for multiple people

diabetes

same as bp_treated, but for the presence of diabetes

smoker

same asbp_treated, but for smoking status

points

logical. Return as points (default) or risk percentage?

...

arguments passed to other methods

combine

logical. Give results as a list of risk_profile objects, or combine the list into an integer vector (default)?

Value

One or more risk profiles (for default method with points = TRUE, or for data frames with combine = FALSE & points = TRUE). Otherwise numeric risk percentage (for points = FALSE, scalars and data frames) or an integer vector (for data frames with combine = TRUE & points = FALSE)

References

D'Agostino et al. (2008)

Examples


cvd_risk(sex = "Female", age = 111, total_cholesterol = 111, systolic = 111,
hdl = 11, bp_treated = FALSE, diabetes = TRUE, smoker = TRUE)


df <- data.frame(
  sex = sample(c("Male", "Female"), 5, TRUE),
  age = sample(30:100, 5, TRUE),
  tc = sample(150:300, 5, TRUE),
  hdl = sample(30:70, 5, TRUE),
  sbp = sample(100:180, 5, TRUE),
  bpmed = sample(c(TRUE, FALSE), 5, TRUE),
  diabetes = sample(c(TRUE, FALSE), 5, TRUE),
  smoker = sample(c(TRUE, FALSE), 5, TRUE)
)

cvd_risk(
  df, sex = "sex", age = "age",
  total_cholesterol = "tc", hdl = "hdl",
  systolic = "sbp", bp_treated = "bpmed",
  diabetes = "diabetes", smoker = "smoker",
  combine = FALSE
)




PAutilities documentation built on Aug. 21, 2022, 9:05 a.m.