rc_plot: Plot long format data

View source: R/rc_plot.R

rc_plotR Documentation

Plot long format data

Description

Creates a grid of plots for each variable in long format data. This function is intended to have data passed from rc_outliers, plotting the record_id field on the x-axis and values on the y-axis. Outliers are colored in red and horizontal indicator lines for +/- 3 standard deviations are included by default. Aside from the standard plots, normal QQ and histograms can also be created using plot_type.

Usage

rc_plot(
  long_data,
  title = NULL,
  plot_type = c("standard", "qq", "hist"),
  outlier_var = NA,
  wrap_var = "variable",
  y = "value",
  x = getOption("redcap_bundle")$id_field,
  legend_position = "none",
  sd_guides = TRUE
)

Arguments

long_data

Dataframe. A long format data frame, as created by rc_outliers. At minimum there should be a record_id column, a variable name column, and a value column. Wide-to-long conversion functions include reshape2::melt(), tidyr::gather(), and tidyr::pivot_longer().

title

Character. Title of the resulting plot.

plot_type

Character. One of 'standard', 'qq', or 'hist'

outlier_var

Character. Name of the column containing logical (T/F) data indicating which values are outliers.

wrap_var

Character. Name of the column containing variable names.

y

Character. Name of the column containing numeric data to be plotted.

x

Character. Field name corresponding to the 'record_id' field.

legend_position

Character. Determines the position of the plot legend. One of 'none', 'top', 'bottom', 'left' or 'right'.

sd_guides

Logical. Determines if standard deviation lines are applied to plots. Only applies to plot_type = 'standard'.

Author(s)

Marcus Lehr


chillywings/rctools documentation built on Aug. 9, 2024, 11:52 p.m.