Description Usage Arguments Details Value Examples
View source: R/plot_functions.R
This function adds one or multiple linearized CDFs to an existing plot grid.
1 2 3 4 5 6 7 8 9 | plot_pop(
p_obj = NULL,
x,
dist_params_tbl,
distribution = c("weibull", "lognormal", "loglogistic", "normal", "logistic", "sev"),
tol = 1e-06,
title_trace = "Population",
plot_method = c("plotly", "ggplot2")
)
|
p_obj |
A plot object to which the population lines are added or
|
x |
A numeric vector of length two or greater used for the x coordinates
of the population line. If |
dist_params_tbl |
A tibble. See 'Details'. |
distribution |
Supposed distribution of the random variable. In the
context of this function |
tol |
The failure probability is restricted to the interval
[tol, 1 - tol]. The default value is in accordance with the decimal
places shown in the hover for |
title_trace |
A character string which is assigned to the trace shown in the legend. |
plot_method |
Plot package, which produces the visual output. Only
used with |
dist_params_tbl
is a data.frame with two or three columns. For
location-scale distributions the first column contains the location parameter
and the second column contains the scale parameter. For three-parametric
distributions the third column contains the threshold parameter.
If only one population line should be displayed, a numeric vector of length
two or three is also supported (c(loc, sc)
or c(loc, sc, thres)
).
A plot object which contains the linearized CDF(s).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | x <- rweibull(n = 100, shape = 1, scale = 20000)
# Example 1 - Two-parametric straight line:
pop_weibull <- plot_pop(
p_obj = NULL,
x = range(x),
dist_params_tbl = c(log(20000), 1),
distribution = "weibull"
)
# Example 2 - Three-parametric curved line:
x2 <- rweibull(n = 100, shape = 1, scale = 20000) + 5000
pop_weibull_2 <- plot_pop(
p_obj = NULL,
x = x2,
dist_params_tbl = c(log(20000 - 5000), 1, 5000),
distribution = "weibull"
)
# Example 3 - Multiple lines:
pop_weibull_3 <- plot_pop(
p_obj = NULL,
x = x,
dist_params_tbl = data.frame(
p_1 = c(log(20000), log(20000), log(20000)),
p_2 = c(1, 1.5, 2)
),
distribution = "weibull",
plot_method = "ggplot2"
)
# Example 4 - Compare two- and three-parametric distributions:
pop_weibull_4 <- plot_pop(
p_obj = NULL,
x = x,
dist_params_tbl = data.frame(
param_1 = c(log(20000), log(20000)),
param_2 = c(1, 1),
param_3 = c(NA, 2)
),
distribution = "weibull"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.