rel.hist: Relative histograms

Description Usage Arguments Value Author(s) See Also Examples

Description

Compute and plot relative histograms with respect to the total or the maximum of the counts.

Usage

1
2
rel.hist(x, breaks = "Sturges", max.normalize = FALSE, add = FALSE,
  ...)

Arguments

x

a vector of values for which the histogram is desired.

breaks

one of:

  • a vector giving the breakpoints between histogram cells,

  • a function to compute the vector of breakpoints,

  • a single number giving the number of cells for the histogram,

  • a character string naming an algorithm to compute the number of cells (see ‘Details’),

  • a function to compute the number of cells.

In the last three cases the number is a suggestion only; as the breakpoints will be set to pretty values, the number is limited to 1e6 (with a warning if it was larger). If breaks is a function, the x vector is supplied to it as the only argument (and the number of breaks is only limited by the amount of available memory).

max.normalize

if TRUE, normalize the counts to their maximum value; else normalize with respect to the sum of the counts (the default).

add

logical. If ‘TRUE’, only the bars are added to the current plot.

...

further arguments passed on to plot.

Value

Invisibly, the resulting object of class "histogram".

Author(s)

Thomas Münch

See Also

hist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x <- rnorm(1000)

# **counts** sum up to one:
h <- rel.hist(x)
sum(h$counts)
# per default, histogram **area** sums up to one:
h <- hist(x, plot = FALSE)
plot(h, freq = FALSE)
sum(h$density) * diff(h$breaks)[1]

# counts normalized to maximum value:
rel.hist(x, max.normalize = TRUE)

thomas-muench/tmlibr documentation built on May 26, 2019, 10:36 a.m.