Learn R Programming

bda (version 3.1.3-2)

histogram: Histogram

Description

To construct histogram based on pre-binned or raw data.

Usage

histogram(x, weights, freq, from, to, nclass, digits=0, rounding)

Arguments

x
A sample. 'NA' values will be automatically removed.
weights
A vector of weights of x
freq
A vector of frequencies of x
from,to
start point, end point of the data.
nclass
Number of classes.
digits
integer indicating the number of decimal places that x will be rounded to. Negative values are allowed. A negative number of digits means rounding to a power of ten, so for example digits = -2 rounds to the nearest hund
rounding
Rounding method. Options include nearest, up, down, or none.

Examples

Run this code
x0 <- rnorm(1000,34.5,1.5)
x <- round(x0)
(out1 <- histogram(x, rounding='nearest',digits=0))
(out2 <- histogram(x0))
par(mfrow=c(2,2))
hist(x0)
plot(out1)
plot(out2)

Run the code above in your browser using DataLab