compare multiple distributions. All based on columns in a data.frame.
Creates several plots based on the integers present in plot
.
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,
...
)
df, invisible
Data.frame with (named) columns.
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
Bandwidth passed to density
for plot 1. DEFAULT: "SJ"
Color (vector). DEFAULT: catPal(ncol(df), alpha=0.3)
Title. DEFAULT: "Distributions of [df name]"
Axis labels for plot 1. DEFAULT: xlab="Values", ylab="Density"
Legend position for plot 1. DEFAULT: "topleft", NULL
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)
Berry Boessenkool, berry-b@gmx.de, Aug 2020
groupHist
fakedata <- data.frame(norm=rnorm(30), exp=rexp(30), unif=runif(30))
compareDist(fakedata)
Run the code above in your browser using DataLab