Learn R Programming

berryFunctions (version 1.22.5)

compareDist: compare distributions

Description

compare multiple distributions. All based on columns in a data.frame. Creates several plots based on the integers present in plot.

Usage

compareDist(
  df,
  plot = 1:4,
  bw = "SJ",
  col = catPal(ncol(df), alpha = 0.3),
  main = paste("Distributions of", deparse(substitute(df))),
  xlab = "Values",
  ylab = "Density",
  legpos1 = "topleft",
  legpos2 = NULL,
  horizontal = FALSE,
  ...
)

Value

df, invisible

Arguments

df

Data.frame with (named) columns.

plot

Integers: which graphics to plot?
Plot 1: overlaid density estimates
Plot 2: multipanel histogram
Plot 3: boxplot
Plot 4: violin plot, if package vioplot is available.
DEFAULT: 1:4

bw

Bandwidth passed to density for plot 1. DEFAULT: "SJ"

col

Color (vector). DEFAULT: catPal(ncol(df), alpha=0.3)

main

Title. DEFAULT: "Distributions of [df name]"

xlab, ylab

Axis labels for plot 1. DEFAULT: xlab="Values", ylab="Density"

legpos1, legpos2

Legend position for plot 1. DEFAULT: "topleft", NULL

horizontal

Should boxplot and vioplot (plot 3 and 4) be horizontal? DEFAULT: FALSE

...

Further arguments passed to polygon (plot 1), groupHist (plot 2) boxplot (plot 3) and vioplot::vioplot (plot 4)

Author

Berry Boessenkool, berry-b@gmx.de, Aug 2020

See Also

groupHist

Examples

Run this code
fakedata <- data.frame(norm=rnorm(30), exp=rexp(30), unif=runif(30))
compareDist(fakedata)

Run the code above in your browser using DataLab