diff --git a/DESCRIPTION b/DESCRIPTION index e6f968eb632c1ffc740cab137fa642355ed4eb97..fdf222593fd0ece78c9b197d728d49f3bba9594a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: stressaddition Type: Package Title: Modelling Tri-Phasic Concentration-Response Relationships -Version: 3.0.3 -Date: 2020-09-21 +Version: 3.1.0 +Date: 2020-10-19 Authors@R: c(person("Sebastian", "Henz", role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index beb7e46ddad9cb1b8a5041e60d198e8341a4b35c..983f36a35980a638c718727c07cd998ec80a0601 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,14 @@ +# stressaddition 3.1.0 + +* Improved the documentation of the `which` argument in `plot_survival()` and `plot_stress()`. +* Changed the default value of the `which` argument in the plot functions. Now it contains the proper default curve names. If it is `NA` only the axes and labels will get drawn. + + # stressaddition 3.0.3 * Added references to the journal article about the Multi-Tox model which was recently published. + # stressaddition 3.0.2 * Fixed a bug where the plotting functions printed `NULL` to the console. diff --git a/R/plot_ecxsys.R b/R/plot_ecxsys.R index 15658e9cff2f3b1c175c3078d681263e43aa55bf..a35f985d429b1d28729d498eae661996be2d03f5 100644 --- a/R/plot_ecxsys.R +++ b/R/plot_ecxsys.R @@ -26,14 +26,15 @@ #' #' @name plot_ecxsys #' -#' @param model The object returned from \code{\link{ecxsys}}. -#' @param which A vector of names to plot. Allowed are the column names of the -#' \code{model$curves} data frame. There is also -#' \code{"survival_tox_observed"} and \code{"survival_tox_env_observed"} for -#' the observed survival and \code{"sys_tox_observed"} and -#' \code{"sys_tox_env_observed"} for the 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 model The model object returned from \code{\link{ecxsys}}. +#' @param which A vector of curve names to plot. Allowed are all values of +#' \code{names(model$curves)} except \code{"concentration"}. See the +#' \emph{Value} section of \code{\link{predict_ecxsys}} for descriptions of +#' these names. Additionally, you can use \code{"survival_tox_observed"} and +#' \code{"survival_tox_env_observed"} for the observed survival and +#' \code{"sys_tox_observed"} and \code{"sys_tox_env_observed"} for the +#' observed Sys. Use \code{"all"} to plot everything or \code{NA} to only draw +#' the axis and labels. Invalid names will be silently ignored. #' #' @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 diff --git a/R/plot_stress.R b/R/plot_stress.R index f3dfd0b43c6f9d2ce7a4aa6bae3325ba4697d6bb..4b027ea8212dd26f6d0a6f21ec83958b6032519d 100644 --- a/R/plot_stress.R +++ b/R/plot_stress.R @@ -20,7 +20,12 @@ #' @rdname plot_ecxsys #' @export plot_stress <- function(model, - which = NA, + which = c( + "sys_tox", + "sys_tox_observed", + "sys_tox_env", + "sys_tox_env_observed" + ), show_legend = FALSE, xlab = "concentration", ylab = "stress", @@ -30,25 +35,15 @@ plot_stress <- function(model, curve_names <- names(model$curves) valid_names <- c( curve_names[startsWith(curve_names, "stress") | startsWith(curve_names, "sys")], - "sys_tox_observed", "sys_tox_env_observed" # the observed points + "sys_tox_observed" ) - 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") - } - } else if ("all" %in% which) { - if (length(which) > 1) { - stop("'all' must not be combined with other curve names.") - } + if (model$with_env) { + valid_names <- c(valid_names, "sys_tox_env_observed") + } + if ("all" %in% which) { 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 stress.") - which <- which[which %in% valid_names] - } else if (any(!which %in% valid_names)) { - warning("Argument 'which' contains invalid names.") - which <- which[which %in% valid_names] + } else { + which <- intersect(which, valid_names) } curves <- model$curves diff --git a/R/plot_survival.R b/R/plot_survival.R index f99d9fb35b3867848562a464f0b0c8f94459092c..7138bca73e1894ec83ef4d7adaf06d5e9d30793b 100644 --- a/R/plot_survival.R +++ b/R/plot_survival.R @@ -20,7 +20,14 @@ #' @rdname plot_ecxsys #' @export plot_survival <- function(model, - which = NA, + which = c( + "survival_tox", + "survival_tox_sys", + "survival_tox_observed", + "survival_tox_env", + "survival_tox_env_sys", + "survival_tox_env_observed" + ), show_legend = FALSE, xlab = "concentration", ylab = "survival", @@ -30,26 +37,15 @@ plot_survival <- function(model, curve_names <- names(model$curves) valid_names <- c( curve_names[startsWith(curve_names, "survival")], - "survival_tox_observed", "survival_tox_env_observed" # observed points + "survival_tox_observed" ) - if (length(which) == 1 && is.na(which)) { - which <- c("survival_tox", "survival_tox_sys", "survival_tox_observed") - if (model$with_env) { - which <- c(which, "survival_tox_env", "survival_tox_env_sys", - "survival_tox_env_observed") - } - } else if ("all" %in% which) { - if (length(which) > 1) { - stop("'all' must not be combined with other curve names.") - } + if (model$with_env) { + valid_names <- c(valid_names, "survival_tox_env_observed") + } + if ("all" %in% which) { 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 stress.") - which <- which[which %in% valid_names] - } else if (any(!which %in% valid_names)) { - warning("Argument 'which' contains invalid names.") - which <- which[which %in% valid_names] + } else { + which <- intersect(which, valid_names) } curves <- model$curves diff --git a/man/plot_ecxsys.Rd b/man/plot_ecxsys.Rd index ae35a65c5a37a28bb4a30f6cb7a0d49995113422..1abfe9912d95c4792a49a98f83ebb520ee14239e 100644 --- a/man/plot_ecxsys.Rd +++ b/man/plot_ecxsys.Rd @@ -9,7 +9,7 @@ \usage{ plot_stress( model, - which = NA, + which = c("sys_tox", "sys_tox_observed", "sys_tox_env", "sys_tox_env_observed"), show_legend = FALSE, xlab = "concentration", ylab = "stress", @@ -18,7 +18,8 @@ plot_stress( plot_survival( model, - which = NA, + which = c("survival_tox", "survival_tox_sys", "survival_tox_observed", + "survival_tox_env", "survival_tox_env_sys", "survival_tox_env_observed"), show_legend = FALSE, xlab = "concentration", ylab = "survival", @@ -26,15 +27,16 @@ plot_survival( ) } \arguments{ -\item{model}{The object returned from \code{\link{ecxsys}}.} +\item{model}{The model object returned from \code{\link{ecxsys}}.} -\item{which}{A vector of names to plot. Allowed are the column names of the -\code{model$curves} data frame. There is also -\code{"survival_tox_observed"} and \code{"survival_tox_env_observed"} for -the observed survival and \code{"sys_tox_observed"} and -\code{"sys_tox_env_observed"} for the 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{which}{A vector of curve names to plot. Allowed are all values of +\code{names(model$curves)} except \code{"concentration"}. See the +\emph{Value} section of \code{\link{predict_ecxsys}} for descriptions of +these names. Additionally, you can use \code{"survival_tox_observed"} and +\code{"survival_tox_env_observed"} for the observed survival and +\code{"sys_tox_observed"} and \code{"sys_tox_env_observed"} for the +observed Sys. Use \code{"all"} to plot everything or \code{NA} to only draw +the axis and labels. Invalid names will be silently ignored.} \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