Skip to content
Snippets Groups Projects
Commit 36d53bc6 authored by Sebastian Henz's avatar Sebastian Henz
Browse files

Fix error with plot_stress() and which = NULL, fixes #41

parent b34ed6a3
No related branches found
No related tags found
1 merge request!30version 3.0.0
Pipeline #3733 passed with stage
in 8 minutes and 12 seconds
......@@ -5,6 +5,7 @@
* Renamed `predict_mixture()` to `multi_tox()`.
* The argument `proportion_ca` in the mixture model `multi_tox()` was renamed and its value reversed. It is now called `sa_contribution` and specifies the proportion of stress addition in the calculation of toxicant stress. To convert your code from the old version use this equation: sa_contribution = 1 - proportion_ca.
* Renamed `stress_tox_sam` to `stress_tox_sa` in the output of `multi_tox()`.
* Fixed a bug where `plot_stress()` with argument `which = NULL` would result in an error. Now it correctly draws the axes without data.
# stressaddition 2.7.0
......
......@@ -58,8 +58,19 @@ plot_stress <- function(model,
model$args$concentration[-1]
)
curves_w <- curves[, which[!endsWith(which, "observed")]]
ymax <- if (NCOL(curves_w) == 0) 1 else max(curves_w, 1, na.rm = TRUE)
if (is.null(which)) {
ymax = 1
} else {
which_lines <- which[!endsWith(which, "observed")]
if (length(which_lines) == 0) {
ymax <- 1
} else {
ymax <- max(curves[, which_lines], 1, na.rm = TRUE)
# No need to include the observed stress in the call to max() no
# matter if those are in "which" or not because these vectors are
# clamped to [0, 1] anyway.
}
}
plot(
NA,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment