| plotDistr | R Documentation |
Plot a probability density, mass, or distribution function.
plotDistr(
x,
p,
discrete = FALSE,
cdf = FALSE,
regions = NULL,
col = "gray",
legend = TRUE,
legend.pos = "topright",
...
)
x |
horizontal coordinates |
p |
vertical coordinates |
discrete |
is the random variable discrete? |
cdf |
is this a cumulative distribution (as opposed to mass) function? |
regions |
for continuous distributions only, if non- |
col |
color for plot, |
legend |
plot a legend of the regions (default |
legend.pos |
position for the legend (see |
... |
arguments to be passed to |
This function plots a probability density, mass, or distribution function, adapting the form of the plot as appropriate.
Produces a plot; returns NULL invisibly.
John Fox
x <- seq(-4, 4, length=100)
plotDistr(x, dnorm(x), xlab="Z", ylab="p(z)", main="Standard Normal Density")
plotDistr(x, dnorm(x), xlab="Z", ylab="p(z)", main="Standard Normal Density",
region=list(c(1.96, Inf), c(-Inf, -1.96)), col=c("red", "blue"), new = TRUE)
plotDistr(x, dnorm(x), xlab="Z", ylab="p(z)", main="Standard Normal Density",
region=list(c(qnorm(0), qnorm(.025)), c(qnorm(.975), qnorm(1)))) # same
x <- 0:10
plotDistr(x, pbinom(x, 10, 0.5), xlab="successes", discrete=TRUE, cdf=TRUE,
main="Binomial Distribution Function, p=0.5, n=10")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.