Learn R Programming

distr6 (version 1.5.6)

lines.Distribution: Superimpose Distribution Functions Plots for a distr6 Object

Description

One of six plots can be selected to be superimposed in the plotting window, including: pdf, cdf, quantile, survival, hazard and cumulative hazard.

Usage

# S3 method for Distribution
lines(x, fun, npoints = 3000, ...)

Arguments

x

distr6 object.

fun

vector of functions to plot, one or more of: "pdf","cdf","quantile", "survival", "hazard", and "cumhazard"; partial matching available.

npoints

number of evaluation points.

...

graphical parameters.

Details

Unlike the plot.Distribution function, no internal checks are performed to ensure that the added plot makes sense in the context of the current plotting window. Therefore this function assumes that the current plot is of the same value support, see examples.

See Also

plot.Distribution for plotting a distr6 object.

Examples

Run this code
# NOT RUN {
plot(Normal$new(mean = 2), "pdf")
lines(Normal$new(mean = 3), "pdf", col = "red", lwd = 2)

# }
# NOT RUN {
# The code below gives examples of how not to use this function.
# Different value supports
plot(Binomial$new(), "cdf")
lines(Normal$new(), "cdf")

# Different functions
plot(Binomial$new(), "pdf")
lines(Binomial$new(), "cdf")

# Too many functions
plot(Binomial$new(), c("pdf", "cdf"))
lines(Binomial$new(), "cdf")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab