diff --git a/DESCRIPTION b/DESCRIPTION index ee2ef22a5e2048a96e0896997d0904805fbeb1fa..f327c51916595e89589a25b0321f3c6b5ad19264 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: stressaddition Type: Package Title: Modeling Tri-Phasic Concentration-Response Relationships -Version: 2.4.1 +Version: 2.5.0 Date: 2020-03-16 Authors@R: c(person("Sebastian", "Henz", diff --git a/NEWS.md b/NEWS.md index bf1b000479f3ffb9cfedc6bf73b020f7a6542bfd..1270c2a73ba20c57598ddc4946250979cef79daf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,8 @@ -# stressaddition 2.4.1 +# stressaddition 2.5.0 * 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`. +* Remove the restriction that the concentration vectors in `predict_mixture()` must be the same length. The longer length must be a multiple of the shorter length because the shorter vector gets recycled to the longer length. # stressaddition 2.4.0 diff --git a/R/predict_mixture.R b/R/predict_mixture.R index 52da7408d59d068ec2d51a9f0a20a0336ebb13a3..f4045cb600fa4a5c5754ee30e536e87c958d11c1 100644 --- a/R/predict_mixture.R +++ b/R/predict_mixture.R @@ -31,7 +31,9 @@ #' #' @param model_a,model_b The ecxsys models of the toxicants. #' @param concentration_a,concentration_b The concentrations of the toxicants in -#' the mixture. Both vectors must be the same length. +#' the mixture. Both vectors must either be the same length or the longer +#' length must be a multiple of the shorter length. That's because the shorter +#' concentration vector gets recycled to the length of the longer one. #' @param proportion_ca The proportion of concentration addition in the #' calculation of the toxicant stress of the mixture. Must be between 0 and 1. #' @param effect_max Controls the scaling of the result. This represents the @@ -61,7 +63,7 @@ #' #' # Example of symmetric prediction: #' conc_a <- c(0, 0.03, 0.3, 3) -#' conc_b <- rep(5.5, 4) +#' conc_b <- 5.5 #' prop_ca <- 0.75 #' mix_a <- predict_mixture(toxicant_a , toxicant_b , conc_a, conc_b, prop_ca) #' mix_b <- predict_mixture(toxicant_b , toxicant_a , conc_b, conc_a, prop_ca) @@ -81,7 +83,6 @@ predict_mixture <- function(model_a, is.numeric(concentration_b), length(concentration_a) > 0, length(concentration_b) > 0, - length(concentration_a) == length(concentration_b), all(!is.na(concentration_a)), all(!is.na(concentration_b)), proportion_ca >= 0, diff --git a/man/predict_mixture.Rd b/man/predict_mixture.Rd index 98c157321a94944bb440a22325d063526a196b17..a769976c97c4e4d8a136dcae1042773fd206b513 100644 --- a/man/predict_mixture.Rd +++ b/man/predict_mixture.Rd @@ -17,7 +17,9 @@ predict_mixture( \item{model_a, model_b}{The ecxsys models of the toxicants.} \item{concentration_a, concentration_b}{The concentrations of the toxicants in -the mixture. Both vectors must be the same length.} +the mixture. Both vectors must either be the same length or the longer +length must be a multiple of the shorter length. That's because the shorter +concentration vector gets recycled to the length of the longer one.} \item{proportion_ca}{The proportion of concentration addition in the calculation of the toxicant stress of the mixture. Must be between 0 and 1.} @@ -63,7 +65,7 @@ predict_mixture( # Example of symmetric prediction: conc_a <- c(0, 0.03, 0.3, 3) -conc_b <- rep(5.5, 4) +conc_b <- 5.5 prop_ca <- 0.75 mix_a <- predict_mixture(toxicant_a , toxicant_b , conc_a, conc_b, prop_ca) mix_b <- predict_mixture(toxicant_b , toxicant_a , conc_b, conc_a, prop_ca) diff --git a/tests/testthat/test-predict_mixture.R b/tests/testthat/test-predict_mixture.R index 0e94dfa9dcc4e0ccf389408cf6cfc5a74ca124d7..a1974bbc89b5db3d8ba344366b0968ef83c0df97 100644 --- a/tests/testthat/test-predict_mixture.R +++ b/tests/testthat/test-predict_mixture.R @@ -38,7 +38,7 @@ test_that("results have not changed", { model_a, model_b, c(0, 0.01, 0.1, 1, 7, 15), - rep(5, 6), + 5, 0.3 )$effect reference <- c(88.574578, 84.361552, 80.633762, 56.730550, 2.882718, 0) @@ -71,7 +71,7 @@ test_that("results have not changed", { test_that("predictions are symmetric", { conc_a <- c(0, 10^seq(log10(0.001), log10(40), length.out = 50)) - conc_b <- rep(3.5, length(conc_a)) + conc_b <- 3.5 prop_ca <- 0.8 effect_12 <- predict_mixture(model_a, model_b, conc_a, conc_b, prop_ca)$effect effect_21 <- predict_mixture(model_b, model_a, conc_b, conc_a, prop_ca)$effect