Skip to contents

eda_dens generates overlapping density distributions for two variables.

Usage

eda_dens(
  x,
  y,
  fac = NULL,
  p = 1L,
  tukey = FALSE,
  fx = NULL,
  fy = NULL,
  grey = 0.6,
  col = "red",
  size = 0.8,
  show.par = TRUE,
  alpha = 0.4,
  xlab = NULL,
  ylab = NULL,
  xaxis = NULL,
  switch = FALSE,
  legend = TRUE,
  ...
)

Arguments

x

Vector for first variable, or a dataframe.

y

Vector for second variable, or column defining the continuous variable if x is a dataframe.

fac

Column defining the categorical variable if x is a dataframe.

p

Power transformation to apply to both sets of values.

tukey

Boolean determining if a Tukey transformation should be adopted (FALSE adopts a Box-Cox transformation).

fx

Formula to apply to x variable. This is computed after any transformation is applied to the x variable.

fy

Formula to apply to y variable. This is computed after any transformation is applied to the y variable.

grey

Grey level to apply to plot elements (0 to 1 with 1 = black).

col

Fill color for second density distribution.

size

Point size (0-1).

show.par

Boolean determining if parameters such as power transformation or formula should be displayed.

alpha

Fill transparency (0 = transparent, 1 = opaque). Only applicable if rgb() is not used to define fill colors.

xlab

X variable label. Ignored if x is a dataframe. This is not the x-axis label!

ylab

Y variable label. Ignored if x is a dataframe. This is not the y-axis label!

xaxis

Label for x-axis. Defaults to "Value".

switch

Boolean determining if the axes should be swapped. Only applies to dataframe input. Ignored if vectors are passed to the function.

legend

Boolean determining if a legend should be added to the plot.

...

Arguments passed to the stats::density() function.

Value

Does not return a value.

Details

This function will generate overlapping density plots with the first variable assigned a grey color and the second variable assigned the default red color.

Examples


 # Passing data as two separate vector objects
 set.seed(207)
 x <- rbeta(1000,2,8)
 y <- x * 1.5 + 0.1
 eda_dens(x, y)

 # Passing data as a dataframe
 dat <- data.frame(val = c(x, y),
                   grp = c(rep("x", length(x)), rep("y", length(y))))
 eda_dens(dat, val, grp)