Learn R Programming

mosaic (version 0.2-3)

distPlot: Plots of Discrete and Continuous Distributions

Description

Provides a simple way to generate plots of pdfs, probability mass functions, cdfs, probability histograms, and normal-quantile plots for distributions known to R.

Usage

distPlot(dist, 
		 params = list(), kind = c("density", "cdf", "qq", "histogram"), 
		 xlab = "", ylab = "", breaks, type, resolution = 5000, ...)

Arguments

dist
A string identifying the distribution. This should work with any distribution that has associated functions beginning with 'd', 'p', and 'q' (e.g, dnorm, pnor
params
a list containing parameters for the distribution
kind
one of "density", "cdf", "qq", or "histogram" (or prefix of any of these)
xlab, ylab
as per other lattice functions
breaks
as per histogram
type
passed along to various lattice graphing functions
resolution
number of points to sample when generating the plots
...
other arguments passed along to lattice graphing routines

Details

distPlot determines whether the distribution is continuous or discrete by seeing if all the sampled quantiles are unique. A discrete random variable with many possible values could fool this algorithm and be considered continuous.

Examples

Run this code
distPlot('norm')
distPlot('norm', type='h')
distPlot('norm', kind='cdf')
distPlot('norm', params=list(mean=100, sd=10), kind='cdf')
distPlot('exp', kind='histogram')
distPlot('binom', params=list( 25, .25))
distPlot('binom', params=list( 25, .25), xlim=c(-1,26) )
distPlot('binom', params=list( 25, .25), kind='cdf')
distPlot('beta', params=list( 3, 10), kind='density')
distPlot('beta', params=list( 3, 10), kind='cdf')

Run the code above in your browser using DataLab