varviolin: Create a scatter plot of an influencing variable and an...

View source: R/varviolin.R

varviolinR Documentation

Create a scatter plot of an influencing variable and an outcome variable

Description

Violin plots of values of an influencing variable (x) and an outcome variable (y) with different intervals of the influencing variable. Determine different possible variable intervals by calculating the optimal interval width for the given variable using the IQR() function in the stats() package of R, after the Freedman-Diaconis rule (IQR = interquartile range).

Usage

varviolin(
  in_var,
  out_var,
  xlab = "Influencing variable",
  ylab = "Outcome variable",
  box_width = 0.1,
  legend_name = "Influencing Variable Intervals",
  ...
)

Arguments

in_var

is a vector of observations of a given influencing variable corresponding to another list with observed values of an outcome variable out_var.

out_var

is a vector of observed values of an outcome variable corresponding to another list with observations of a given influencing variable in_var.

xlab

is a label for the influencing variable in_var on the x axis, the default label is "Influencing variable".

ylab

is a label for the outcome variable out_var on the y axis, the default label is "Outcome variable".

box_width

is a number between 0 and 1 for the desired width of the violins in the plot. The default is 0.1.

legend_name

is a label for the legend, the default label is "Influencing Variable Intervals".

...

arguments passed to ggplot2::theme

Examples

in_var <- sample(x = 1:50, size = 20, replace = TRUE)
out_var <- sample(x = 1000:5000, size = 20, replace = TRUE)
varviolin(in_var, out_var)


CWWhitney/uncertainty documentation built on June 14, 2022, 10:21 p.m.