Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

discrete.histogram

Histogram for Discrete Distributions


Description

Creates a prettier histogram for discrete distributions

Usage

discrete.histogram (x, prob, prob2=NULL, prob3=NULL,
    xlab="x", xaxs.label=NULL, yaxs.label=NULL, bar.width=NULL,
    freq=FALSE, prob.col="blue", prob2.col="red", prob3.col="gray", ...)

Arguments

x

The vector of x's

prob

The probabilities for the x's

prob2

A second vector of probabilities of the x's

prob3

A third vector of probabilities of the x's

xlab

Label for the x axis

xaxs.label

Label for the x's

yaxs.label

Label for the y axis

bar.width

Width of the bars

freq

If TRUE, shows a frequency histogram as opposed to probability.

prob.col

The color of the first set of histogram bars.

prob2.col

The color of the second set of histogram bars.

prob3.col

The color of the third set of histogram bars.

...

Additional arguments passed to function plot

Details

This function displays a histogram for discrete probability distributions.

Examples

a <- c(3,4,0,0,5,1,1,1,1,0)
discrete.histogram (a)

x <- c(0,1,3,4,5)
p <- c(.3,.4,.1,.1,.1)
discrete.histogram (x,p)

x <- c(0,1,3,4,5)
y <- c(3,4,1,1,1)
discrete.histogram (x,y)

arm

Data Analysis Using Regression and Multilevel/Hierarchical Models

v1.11-2
GPL (> 2)
Authors
Andrew Gelman [aut], Yu-Sung Su [aut, cre], Masanao Yajima [ctb], Jennifer Hill [ctb], Maria Grazia Pittau [ctb], Jouni Kerman [ctb], Tian Zheng [ctb], Vincent Dorie [ctb]
Initial release
2020-7-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.