Learn R Programming

extracat (version 1.7-6)

ahist: Histogram using active bins

Description

A standard histogram using getbw to compute the binwidth and breakpoints.

Usage

ahist(x, k = NULL, m = NULL, fun = "qplot", col = "grey", ival = NULL)

Arguments

x

A numeric vector.

k

The desired number of active bins. A bin is active if it contains at least min_n observations. The default is k <- 1 + 2*ceiling(log(N)/log(2)).

m

The minimum number of observations necessary for a bin to count as an active bin. Defaults to m = max(log(N/10)/log(10),1).

fun

Either "qplot" or "hist".

col

The color for the bars.

ival

If this is set to a numeric value in (0,1) then x is trimmed according to innerval(x, p = ival).

Value

The ggplot object.

See Also

getbw, cutbw

Examples

Run this code
# NOT RUN {
ahist(rnorm(100))
ahist(rnorm(1000))
ahist(rnorm(10000))


ahist(rexp(100))
ahist(rexp(1000))
ahist(rexp(10000))


# }
# NOT RUN {
ahist(rcauchy(1000))
ahist(rcauchy(1000), ival = 0.95)

x <- c(rnorm(400),rnorm(200, mean=6))
ahist(x)

x <- c(rnorm(400),rnorm(200, mean=16))
ahist(x)


x <- c(rnorm(400),rnorm(200, mean=32))
ahist(x)
# }

Run the code above in your browser using DataLab