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

Set default "which" value to NA. Use empty vectors or NULL to show just the axes.

parent 26f41388
No related branches found
No related tags found
1 merge request!27Some bugfixes and more flexible concentration lengths
Package: stressaddition
Type: Package
Title: Modeling Tri-Phasic Concentration-Response Relationships
Version: 2.4.0
Date: 2020-03-13
Version: 2.4.1
Date: 2020-03-16
Authors@R: c(person("Sebastian",
"Henz",
role = c("aut", "cre"),
......
# stressaddition 2.4.1
* Fixed unintended behaviour in `plot_effect()` and `plot_stress()` where supplying an empty vector caused the four standard curves to show. Now setting `which` to an empty vector or `NULL` shows just the axes. The default value is NA.
* Renamed the `mixture_effect` column in the `predict_mixture` output data frame to `effect`.
# stressaddition 2.4.0
* Improved `plot_effect()` and `plot_stress()`. You can now control whether the observed values (the points) should be plotted using the `which` argument.
......
......@@ -31,8 +31,9 @@
#' \code{model$curves} data frame. There is also \code{"effect_tox_observed"}
#' and \code{"effect_tox_env_observed"} for the observed effects and
#' \code{"sys_tox_observed"} and \code{"sys_tox_env_observed"} for the
#' observed Sys. The default \code{NULL} only plots the most important curves.
#' Use \code{which = "all"} to display all curves.
#' observed Sys. The default \code{NA} only plots the most important curves.
#' Use \code{which = "all"} to display all curves. An empty vector or
#' \code{NULL} creates just the axes.
#'
#' @param show_legend Should the plot include a legend? Defaults to \code{FALSE}
#' because it may cover some parts of the plot depending on the plot size and
......
......@@ -20,7 +20,7 @@
#' @rdname plot_ecxsys
#' @export
plot_effect <- function(model,
which = NULL,
which = NA,
show_legend = FALSE,
xlab = "concentration",
ylab = "effect",
......@@ -32,7 +32,7 @@ plot_effect <- function(model,
curve_names[startsWith(curve_names, "effect")],
"effect_tox_observed", "effect_tox_env_observed" # the observed points
)
if (is.null(which)) {
if (length(which) == 1 && is.na(which)) {
which <- c("effect_tox", "effect_tox_sys", "effect_tox_observed")
if (model$with_env) {
which <- c(which, "effect_tox_env", "effect_tox_env_sys",
......@@ -43,12 +43,12 @@ plot_effect <- function(model,
stop("'all' must not be combined with other curve names.")
}
which <- valid_names
} else if (!model$with_env && any(grepl("env", which, fixed = TRUE))) {
warning("'which' contains names with 'env' but the model was built ",
"without environmental effects.")
which <- which[which %in% valid_names]
} else if (any(!which %in% valid_names)) {
warning("Argument 'which' contains invalid names.")
if (!model$with_env && any(grepl("env", which, fixed = TRUE))) {
warning("'which' contains names with 'env' but the model was",
" built without environmental effects.")
}
which <- which[which %in% valid_names]
}
......
......@@ -20,7 +20,7 @@
#' @rdname plot_ecxsys
#' @export
plot_stress <- function(model,
which = NULL,
which = NA,
show_legend = FALSE,
xlab = "concentration",
ylab = "stress",
......@@ -32,7 +32,7 @@ plot_stress <- function(model,
curve_names[startsWith(curve_names, "stress") | startsWith(curve_names, "sys")],
"sys_tox_observed", "sys_tox_env_observed" # the observed points
)
if (is.null(which)) {
if (length(which) == 1 && is.na(which)) {
which <- c("sys_tox", "sys_tox_observed")
if (model$with_env) {
which <- c(which, "sys_tox_env", "sys_tox_env_observed")
......@@ -42,12 +42,12 @@ plot_stress <- function(model,
stop("'all' must not be combined with other curve names.")
}
which <- valid_names
} else if (!model$with_env && any(grepl("env", which, fixed = TRUE))) {
warning("'which' contains names with 'env' but the model was built ",
"without environmental effects.")
which <- which[which %in% valid_names]
} else if (any(!which %in% valid_names)) {
warning("Argument 'which' contains invalid names.")
if (!model$with_env && any(grepl("env", which, fixed = TRUE))) {
warning("'which' contains names with 'env' but the model was",
" built without environmental effects.")
}
which <- which[which %in% valid_names]
}
......
......@@ -8,7 +8,7 @@
\usage{
plot_effect(
model,
which = NULL,
which = NA,
show_legend = FALSE,
xlab = "concentration",
ylab = "effect",
......@@ -17,7 +17,7 @@ plot_effect(
plot_stress(
model,
which = NULL,
which = NA,
show_legend = FALSE,
xlab = "concentration",
ylab = "stress",
......@@ -31,8 +31,9 @@ plot_stress(
\code{model$curves} data frame. There is also \code{"effect_tox_observed"}
and \code{"effect_tox_env_observed"} for the observed effects and
\code{"sys_tox_observed"} and \code{"sys_tox_env_observed"} for the
observed Sys. The default \code{NULL} only plots the most important curves.
Use \code{which = "all"} to display all curves.}
observed Sys. The default \code{NA} only plots the most important curves.
Use \code{which = "all"} to display all curves. An empty vector or
\code{NULL} creates just the axes.}
\item{show_legend}{Should the plot include a legend? Defaults to \code{FALSE}
because it may cover some parts of the plot depending on the plot size and
......
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