bp_mag: Blood Pressure Magnitude (Peak and Trough)

View source: R/bp_mag.R

bp_magR Documentation

Blood Pressure Magnitude (Peak and Trough)

Description

Calculate the Peak and Trough defined as the max BP - average BP and average BP - min BP, respectively.

Usage

bp_mag(
  data,
  inc_date = FALSE,
  subj = NULL,
  bp_type = c("both", "sbp", "dbp"),
  add_groups = NULL,
  inc_wake = TRUE
)

Arguments

data

Required argument. Pre-processed dataframe with SBP and DBP columns with optional ID, VISIT, WAKE, and DATE columns if available. Use process_data to properly format data.

inc_date

Optional argument. Default is FALSE. As ABPM data typically overlaps due to falling asleep on one date and waking up on another, the inc_date argument is typically kept as FALSE, but the function will work regardless. Setting inc_date = TRUE will include these dates as a grouping level.

subj

Optional argument. Allows the user to specify and subset specific subjects from the ID column of the supplied data set. The subj argument can be a single value or a vector of elements. The input type should be character, but the function will comply with integers so long as they are all present in the ID column of the data.

bp_type

Optional argument. Determines whether to calculate magnitude for SBP values or DBP values, or both. For both SBP and DBP ARV values use bp_type = 'both', for SBP-only use bp_type = 'sbp, and for DBP-only use bp_type = 'dbp'. If no type specified, default will be set to 'both'

add_groups

Optional argument. Allows the user to aggregate the data by an additional "group" to further refine the output. The supplied input must be a character vector with the strings corresponding to existing column names of the processed data input supplied. Capitalization of add_groups does not matter. Ex: add_groups = c("Time_of_Day")

inc_wake

Optional argument corresponding to whether or not to include WAKE in the grouping of the final output (if WAKE column is available). By default, inc_wake = TRUE which will include the WAKE column in the groups by which to calculate the respective metrics.

Value

A tibble object with a row corresponding to each subject, or alternatively a row corresponding to each date if inc_date = TRUE. The resulting tibble consists of:

  • ID: The unique identifier of the subject. For single-subject datasets, ID = 1

  • VISIT: (If applicable) Corresponds to the visit # of the subject, if more than 1

  • WAKE: (If applicable) Corresponds to the awake status of the subject (0 = asleep | 1 = awake)

  • Peak_SBP / Peak_DBP: Measures the difference between the max value and the average

  • Trough_SBP / Trough_DBP: Measures the difference between the average and the min value

  • N: The number of observations for that particular grouping. If inc_date = TRUE, N corresponds to the number of observations for that date. If inc_date = FALSE, N corresponds to the number of observations for the most granular grouping available (i.e. a combination of ID, VISIT, and WAKE)

  • Any add_groups variables supplied to function argument will be present as a column in the resulting tibble.

Examples

# Load data
data(bp_hypnos)
data(bp_jhs)

# Process bp_hypnos
hyp_proc <- process_data(bp_hypnos, sbp = "SYST", dbp = "DIAST", date_time = "date.time",
id = "id", wake = "wake", visit = "visit", hr = "hr", pp ="pp", map = "map", rpp = "rpp")
# Process bp_jhs data
jhs_proc <- process_data(bp_jhs, sbp = "Sys.mmHg.", dbp = "Dias.mmHg.", date_time = "DateTime",
hr = "Pulse.bpm.")

# BP Magnitude Calculation
bp_mag(hyp_proc)
bp_mag(jhs_proc, inc_date = TRUE)

bp documentation built on May 10, 2022, 5:12 p.m.