Plot a histogram of binned elements with binning information.

plotBinHist(
  x,
  b,
  breaks = 10 * nlevels(b),
  xlab = deparse(substitute(x, env = as.environment(-1))),
  ylab = "Frequency",
  main = "",
  legend = "topright",
  legend.cex = 1,
  ...
)

Arguments

x

A numerical vector with the values used for binning.

b

A factor that groups elements of x into bins (typically the output of bin).

breaks

Controls the histogram breaks (passed to hist(...)).

xlab

Label for x-axis.

ylab

Label for y-axis.

main

Main title.

legend

If not NULL, draw a legend with binning information (will be passed to legend(x=legend) to control legend position).

legend.cex

A scalar that controls the text size in the legend relative to the current par("cex") (see legend).

...

Further arguments passed to getColsByBin.

Value

Invisibly the return value of hist(...) that generated the plot.

See also

Examples

set.seed(1)
x <- rnorm(100)
b <- bin(x, "equalN", nElements = 10)
plotBinHist(x, b)