Learn R Programming

bda (version 2.0.11-4)

histogram: Draw histogram based on data with rounding errors

Description

Draw histogram based on data with rounding errors.

Usage

histogram(x, w, nclass, binwidth, lb,
      range.x, freq=FALSE, truncate = TRUE)

Arguments

x
a numeric value or a vector.
w
A vector of weights for the values of x
nclass
Number of classes
binwidth
bin width.
lb
Lower bound of the first bin.
range.x
The range of x where the histogram will be constructed.
freq
Whether w (if given) are frequencies.
truncate
Whether or not to truncate the data fall beyond the range.x.

Value

  • A class hist is returned, where a component plot is an R object "histogram" for visualization.

Details

If nclass is missing and the data are not prebinned, the cross validation score based binwidth selector will be used by default. If the data is pre-binned, the histogram will be constructed by using the relative frequencies in weights, or constructed using table if weights is missing.

References

Wang, B. and Wertelecki, W. (2012) Density Estimation for Data With Rounding Errors. Computational Statistics and Data Analysis, (in press), doi: 10.1016/j.csda.2012.02.016.

See Also

hist.

Examples

Run this code
ofc = round(rnorm(1000,34.5,1.5))
 (out = histogram(ofc,lb=min(ofc)-0.5, binwidth=1))
 plot(out)
 x0 = seq(28,42, length=100)
 lines(dnorm(x0,34.5,1.5)~x0, col=2)

Run the code above in your browser using DataLab