Learn R Programming

weibulltools (version 1.0.1)

plot_pop: Add Population Line to an Existing Grid

Description

This function adds a linearized CDF to an existing plotly grid.

Usage

plot_pop(p_obj, x, params, distribution = c("weibull", "lognormal",
  "loglogistic"), color = I("#FF0000"), title_trace = "Population")

Arguments

p_obj

a plotly object, which at least includes the layout provided by plot_layout.

x

a numeric vector containing the x-coordinates of the population line.

params

a (named) numeric vector, where the first entry is the location parameter \(\mu\) and the second entry is the scale parameter \(\sigma\) of a lognormal or loglogistic distribution. If the distribution value is "weibull" the first entry must be the scale parameter \(\eta\) and the second entry must be the shape parameter \(\beta\). Parametrization is the same used in rweibull.

distribution

supposed distribution of the random variable. The value can be "weibull", "lognormal" or "loglogistic". Other distributions have not been implemented yet.

color

the color of the population line should be added as follows: For hexadecimal codes: color = I("#3C8DBC") and for a color specified with a string: color = I("blue").

title_trace

a character string which is assigned to the trace shown in the legend.

Value

A plotly object which contains the supposed linearized population CDF. Failure probabilities must be strictly below 1 and for this very reason

Examples

Run this code
# NOT RUN {
x <- rweibull(n = 100, shape = 1, scale = 20000)
grid_weibull <- plot_layout(x = x,
                            distribution = "weibull",
                            title_main = "Weibull Analysis",
                            title_x = "Time to Failure",
                            title_y = "Failure Probability")
pop_weibull <- plot_pop(p_obj = grid_weibull,
                        x = x, params = c(20000, 1),
                        distribution = "weibull", color = I("green"),
                        title_trace = "Population")

# }

Run the code above in your browser using DataLab