histogram: Histogram Plots

View source: R/histogram.R

histogramR Documentation

Histogram Plots

Description

Create a histogram of single variables.

Usage

histogram(x, data, type = "count", fit, ...)

Arguments

x

formula. An expression of the form ~ x | z where x is the variable we want to make histograms for and z is a second, optional, variable we would like to use for faceting.

data

data frame. The data where the variables can be found.

type

character. A character string that describes what units the user would like on the y-axis. Options include "count" for frequencies, "percent" for percentages and "density" which can be used when adding fitted lines.

fit

character. A character string that describes a probablility density curve to overlay on the histogram of the data. Distributions that can be used are "normal", "beta", "cauchy", "chisq" (similarly "chi-squared"), "exponential", "gamma", "geometric", "lognormal", "poisson", "t" and "weibull"

nint

number. The number of bins to use in the histogram

breaks

Usually a numeric vector of length (number of bins + 1) defining the breakpoints of the bins. Note that when breakpoints are not equally spaced, the only value of type that makes sense is density.

Note

For additional options for creating histogram, look at the help file found in the lattice package or run help(histogram, package="lattice") in the console.

Examples

data(cdc)
histogram(~height, data = cdc)
histogram(~height, data = cdc, fit = "normal")
histogram(~height | gender, data = cdc)


mobilizingcs/mobilizr documentation built on May 5, 2024, 1:01 a.m.