eda_dens: Overlapping density distributions for two variables

View source: R/eda_dens.R

eda_densR Documentation

Overlapping density distributions for two variables

Description

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,
  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 grouping 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.

ylab

Y variable label. Ignored if x is a dataframe.

legend

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

...

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

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.

Value

Does not return a value.

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)

mgimond/tukeyedar documentation built on March 19, 2024, 8:44 a.m.