bp_report: Blood Pressure Report

View source: R/bp_report.R

bp_reportR Documentation

Blood Pressure Report

Description

The bp_report function serves to aggregate various data visuals and metrics pertaining to the supplied data set into a clean formatted report.

Usage

bp_report(
  data,
  subj = NULL,
  inc_low = TRUE,
  inc_crisis = TRUE,
  group_var = NULL,
  save_report = TRUE,
  path = NULL,
  filename = "bp_report",
  width = 11,
  height = 8.5,
  filetype = "pdf",
  units = "in",
  scale = 1.25,
  plot = TRUE,
  hist_bins = 30
)

Arguments

data

Required argument. A processed dataframe resulting from the process_data function to properly format data set. In order for the bp_report function to work properly, the following variables must be present and properly formatted:

  • SBP

  • DBP

  • DATE_TIME - Used in the process_data function to create additional columns that are needed for the bp_report function (SBP_Category, DBP_Category, Weekday, and Time_of_Day.)

  • SBP_CATEGORY - Automatically calculated in the process_data function

  • DBP_CATEGORY - Automatically calculated in the process_data function

  • DAY_OF_WEEK - Automatically calculated in the process_data function

  • TIME_OF_DAY - Automatically calculated in the process_data function

  • ID - (If applicable) Used for separating out different individuals, if more than one

  • VISIT - (If applicable) Used for separating out an individuals' different visits, if more than one

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.

inc_low

Optional logical argument dictating whether or not to include the "Low" category for BP classification column (and the supplementary SBP/DBP Category columns). Default set to TRUE.

inc_crisis

Optional logical argument dictating whether or not to include the "Crisis" category for BP classification column (and the supplementary SBP/DBP Category columns). Default set to TRUE.

group_var

A categorical column of the input data set that the individual points are to be grouped / separated by for a given plot. Cannot contain more than 10 levels (to avoid overcrowding the plot). This is different from the wrap_var argument which segments plots by category and cannot be used with the process_data function.

save_report

A logical value indicating whether to save the BP report output as a separate file. The default is TRUE indicating that the report will be saved.

path

Optional argument. A string corresponding to the respective file path by which the report is to be saved. Do not include trailing slashes (i.e. ~/loc/) or the file name (i.e. ~/loc/testfile.pdf). By default, if not path argument specified, will save at the current working directory.

filename

Optional argument. A string corresponding to the name of the report. The default is "bp_report". The string cannot begin with a number or non-alphabetical character.

Note: DO NOT include the file type extension (such as ".pdf" or ".png") at the end of the string; the bp_report function will automatically join the name with the file type.

width

Optional argument. An numeric value corresponding to the width of the output document. The default is set to 12 inches.

height

Optional argument. An numeric value corresponding to the height of the output document. The default is set to 8.53 inches.

filetype

A string corresponding to he particular type of file that the report is to be saved as. Although PDF is the default possible options include:

  • pdf (default)

  • png

  • jpeg

  • tiff

  • bmp

  • eps

  • ps

units

A character string corresponding to the unit of measurement that the width and height correspond to in the exported output. The default is inches ("in"), but centimeters ("cm") and millimeters ("mm") are also available.

scale

A multiplicative scaling factor for the report output.

plot

A logical value indicating whether to automatically produce the plot of bp_report, or suppress the output. The default value is TRUE. If false, the returned object is a grob that can be plotted using grid.arrange

hist_bins

An integer specifying how many bins to use for histogram plots. This is a ggplot parameter; default value set to 30

Value

If plot = TRUE, the function produces a plot of BP report that contains scatterplot of BP values by stages (see bp_scatter), histograms of BP values by stages (see bp_hist) and frequency tables of BP values by stages and day of the week/time of the day (see dow_tod_plots). If plot = FALSE, the function returns the grob object that can be plotted later using grid.arrange. If save_report = TRUE, the report will be automatically saved at the current working directory (can be checked using getwd()) or at specified file path.

Examples


data("bp_jhs")
data("bp_hypnos")
hyp_proc <- process_data(bp_hypnos,
                         sbp = "syst",
                         dbp = "DIAST",
                         date_time = "date.time",
                         id = "id",
                         wake = "wake",
                         visit = "visit",
                         hr = "hr",
                         map = "map",
                         rpp = "rpp",
                         pp = "pp",
                         ToD_int = c(5, 13, 18, 23))

jhs_proc <- process_data(bp_jhs,
                         sbp = "Sys.mmHg.",
                         dbp = "Dias.mmHg.",
                         date_time = "DateTime",
                         hr = "pulse.bpm.")
rm(bp_hypnos, bp_jhs)

## Not run: 
# Single-subject Report
# save_report = FALSE for illustrative purposes
# plot = TRUE will automatically generate a plot
bp_report(jhs_proc, save_report = FALSE, plot = TRUE)

# Multi-subject Report
# save_report = FALSE for illustrative purposes
# plot = FALSE will suppress the plot output and return a grob object
out = bp_report(hyp_proc, group_var = 'VISIT', save_report = FALSE, plot = FALSE)
gridExtra::grid.arrange(out)

## End(Not run)

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