diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | DESCRIPTION | 8 | ||||
-rw-r--r-- | GNUmakefile | 2 | ||||
-rw-r--r-- | R/PEC_sw_focus.R | 19 | ||||
-rw-r--r-- | R/reexports.R | 5 | ||||
-rw-r--r-- | R/set_nd_nq.R | 164 | ||||
-rw-r--r-- | build.log | 2 | ||||
-rw-r--r-- | man/PEC_sw_focus.Rd | 10 | ||||
-rw-r--r-- | man/TOXSWA_cwa.Rd | 30 | ||||
-rw-r--r-- | man/reexports.Rd | 17 | ||||
-rw-r--r-- | man/set_nd_nq.Rd | 103 | ||||
-rw-r--r-- | test.log | 15 | ||||
-rw-r--r-- | tests/testthat/test_set_nd.R | 86 |
13 files changed, 75 insertions, 398 deletions
@@ -1,3 +1,15 @@ +commit aa0c59c7a3ede267730fe85f9e27b1814f9e897a +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2021-11-19 00:18:41 +0100 + + Update static docs + +commit f4e35b0bf9c4de0b5c6235f5cf9e284faf40569f +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2021-11-19 00:17:33 +0100 + + Update docs and logs + commit 6e3917d814500d5af43702b4d4be1e44cefc00d4 Author: Johannes Ranke <jranke@uni-bremen.de> Date: 2021-11-18 11:22:44 +0100 diff --git a/DESCRIPTION b/DESCRIPTION index bb7e74d..e6bbe21 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: pfm Type: Package Title: Utilities for Pesticide Fate Modelling -Version: 0.5.8 -Date: 2021-11-19 +Version: 0.5.9 +Date: 2022-09-29 Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-4371-6538")) @@ -11,7 +11,7 @@ Description: Utilities for simple calculations of predicted environmental pesticide fate modelling software packages. Depends: R6, - mkin (>= 0.9.50.2) + mkin (>= 1.1.2) Imports: graphics, readr, @@ -32,4 +32,4 @@ LazyLoad: yes LazyData: yes Encoding: UTF-8 URL: https://pkgdown.jrwb.de/pfm -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.1 diff --git a/GNUmakefile b/GNUmakefile index aeb09e2..0724630 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -57,7 +57,7 @@ winbin: $(WINBIN) test: build @echo "Running testthat tests..." - NOT_CRAN=true "$(R_HOME)/bin/Rscript" -e 'devtools::test()' 2>&1 | tee test.log + NOT_CRAN=true "$(R_HOME)/bin/Rscript" -e 'options(cli.dynamic = TRUE); devtools::test()' 2>&1 | tee test.log sed -i -e "s/\r.*\r//" test.log @echo "DONE." diff --git a/R/PEC_sw_focus.R b/R/PEC_sw_focus.R index c01dece..4d5139e 100644 --- a/R/PEC_sw_focus.R +++ b/R/PEC_sw_focus.R @@ -24,24 +24,24 @@ #' @note Step 2 is not implemented. #' @export #' @param parent A list containing substance specific parameters, e.g. -#' conveniently generated by \code{\link{chent_focus_sw}}. +#' conveniently generated by [chent_focus_sw]. #' @param rate The application rate in g/ha. Overriden when #' applications are given explicitly #' @param n The number of applications #' @param i The application interval #' @param comment A comment for the input file #' @param met A list containing metabolite specific parameters. e.g. -#' conveniently generated by \code{\link{chent_focus_sw}}. If not NULL, +#' conveniently generated by [chent_focus_sw]. If not NULL, #' the PEC is calculated for this compound, not the parent. #' @param f_drift The fraction of the application rate reaching the waterbody #' via drift. If NA, this is derived from the scenario name and the number #' of applications via the drift data defined by the -#' \code{\link{FOCUS_Step_12_scenarios}} +#' [FOCUS_Step_12_scenarios] #' @param f_rd The fraction of the amount applied reaching the waterbody via #' runoff/drainage. At Step 1, it is assumed to be 10%, be it the #' parent or a metabolite #' @param scenario The name of the scenario. Must be one of the scenario -#' names given in \code{\link{FOCUS_Step_12_scenarios}} +#' names given in [FOCUS_Step_12_scenarios] #' @param region 'n' for Northern Europe or 's' for Southern Europe. If NA, only #' Step 1 PECsw are calculated #' @param season 'of' for October to February, 'mm' for March to May, and 'js' @@ -64,7 +64,7 @@ #' #' # Metabolite #' new_dummy <- chent_focus_sw("New Dummy", mw = 250, Koc = 100) -#' M1 <- chent_focus_sw("M1", mw = 100, cwsat = 100, DT50_ws = 100, Koc = 50, +#' M1 <- chent_focus_sw("M1", mw = 100, cwsat = 100, DT50_ws = 100, Koc = 50, #' max_ws = 0, max_soil = 0.5) #' PEC_sw_focus(new_dummy, 1000, scenario = "cereals, winter", met = M1) PEC_sw_focus <- function(parent, rate, n = 1, i = NA, @@ -81,8 +81,9 @@ PEC_sw_focus <- function(parent, rate, n = 1, i = NA, { if (n > 1 & is.na(i)) stop("Please specify the interval i if n > 1") + scenario = match.arg(scenario) + if (is.na(f_drift)) { - scenario = match.arg(scenario) f_drift = FOCUS_Step_12_scenarios$drift[scenario, "1"] / 100 # For Step 2 we would select the reduced percentiles for multiple apps: if (n <= 8) { @@ -128,7 +129,6 @@ PEC_sw_focus <- function(parent, rate, n = 1, i = NA, } on.exit(close(txt)) - scenario = match.arg(scenario) region = match.arg(region) season = match.arg(season) interception = match.arg(interception) @@ -179,10 +179,11 @@ PEC_sw_focus <- function(parent, rate, n = 1, i = NA, reg_sea = reg_code + sea_code } + scenario_safe <- sub(" /", " or", scenario) if (is.null(met)) { - name_input <- paste(parent$name, scenario, region, season) + name_input <- paste(parent$name, scenario_safe, region, season) } else { - name_input <- paste(met$name, scenario, region, season) + name_input <- paste(met$name, scenario_safe, region, season) } if (comment != "") name_input = paste(name_input, comment) diff --git a/R/reexports.R b/R/reexports.R new file mode 100644 index 0000000..0fa6df5 --- /dev/null +++ b/R/reexports.R @@ -0,0 +1,5 @@ +#' @export +mkin::set_nd_nq + +#' @export +mkin::set_nd_nq_focus diff --git a/R/set_nd_nq.R b/R/set_nd_nq.R deleted file mode 100644 index 37b9a89..0000000 --- a/R/set_nd_nq.R +++ /dev/null @@ -1,164 +0,0 @@ -#' Set non-detects and unquantified values in residue series without replicates -#' -#' This function automates replacing unquantified values in residue time and -#' depth series. For time series, the function performs part of the residue -#' processing proposed in the FOCUS kinetics guidance for parent compounds -#' and metabolites. For two-dimensional residue series over time and depth, -#' it automates the proposal of Boesten et al (2015). -#' -#' @param res_raw Character vector of a residue time series, or matrix of -#' residue values with rows representing depth profiles for a specific sampling -#' time, and columns representing time series of residues at the same depth. -#' Values below the limit of detection (lod) have to be coded as "nd", values -#' between the limit of detection and the limit of quantification, if any, have -#' to be coded as "nq". Samples not analysed have to be coded as "na". All -#' values that are not "na", "nd" or "nq" have to be coercible to numeric -#' @param lod Limit of detection (numeric) -#' @param loq Limit of quantification(numeric). Must be specified if the FOCUS rule to -#' stop after the first non-detection is to be applied -#' @param time_zero_presence Do we assume that residues occur at time zero? -#' This only affects samples from the first sampling time that have been -#' reported as "nd" (not detected). -#' @references Boesten, J. J. T. I., van der Linden, A. M. A., Beltman, W. H. -#' J. and Pol, J. W. (2015). Leaching of plant protection products and their -#' transformation products; Proposals for improving the assessment of leaching -#' to groundwater in the Netherlands — Version 2. Alterra report 2630, Alterra -#' Wageningen UR (University & Research centre) -#' @references FOCUS (2014) Generic Guidance for Estimating Persistence and Degradation -#' Kinetics from Environmental Fate Studies on Pesticides in EU Registration, Version 1.1, -#' 18 December 2014, p. 251 -#' @return A numeric vector, if a vector was supplied, or a numeric matrix otherwise -#' @export -#' @examples -#' # FOCUS (2014) p. 75/76 and 131/132 -#' parent_1 <- c(.12, .09, .05, .03, "nd", "nd", "nd", "nd", "nd", "nd") -#' set_nd_nq(parent_1, 0.02) -#' parent_2 <- c(.12, .09, .05, .03, "nd", "nd", .03, "nd", "nd", "nd") -#' set_nd_nq(parent_2, 0.02) -#' set_nd_nq_focus(parent_2, 0.02, loq = 0.05) -#' parent_3 <- c(.12, .09, .05, .03, "nd", "nd", .06, "nd", "nd", "nd") -#' set_nd_nq(parent_3, 0.02) -#' set_nd_nq_focus(parent_3, 0.02, loq = 0.05) -#' metabolite <- c("nd", "nd", "nd", 0.03, 0.06, 0.10, 0.11, 0.10, 0.09, 0.05, 0.03, "nd", "nd") -#' set_nd_nq(metabolite, 0.02) -#' set_nd_nq_focus(metabolite, 0.02, 0.05) -#' # -#' # Boesten et al. (2015), p. 57/58 -#' table_8 <- matrix( -#' c(10, 10, rep("nd", 4), -#' 10, 10, rep("nq", 2), rep("nd", 2), -#' 10, 10, 10, "nq", "nd", "nd", -#' "nq", 10, "nq", rep("nd", 3), -#' "nd", "nq", "nq", rep("nd", 3), -#' rep("nd", 6), rep("nd", 6)), -#' ncol = 6, byrow = TRUE) -#' set_nd_nq(table_8, 0.5, 1.5, time_zero_presence = TRUE) -#' table_10 <- matrix( -#' c(10, 10, rep("nd", 4), -#' 10, 10, rep("nd", 4), -#' 10, 10, 10, rep("nd", 3), -#' "nd", 10, rep("nd", 4), -#' rep("nd", 18)), -#' ncol = 6, byrow = TRUE) -#' set_nd_nq(table_10, 0.5, time_zero_presence = TRUE) -set_nd_nq <- function(res_raw, lod, loq = NA, time_zero_presence = FALSE) { - if (!is.character(res_raw)) { - stop("Please supply a vector or a matrix of character values") - } - if (is.vector(res_raw)) { - was_vector <- TRUE - res_raw <- as.matrix(res_raw) - } else { - was_vector <- FALSE - if (!is.matrix(res_raw)) { - stop("Please supply a vector or a matrix of character values") - } - } - nq <- 0.5 * (loq + lod) - nda <- 0.5 * lod # not detected but adjacent to detection - res_raw[res_raw == "nq"] <- nq - - if (!time_zero_presence) { - for (j in 1:ncol(res_raw)) { - if (res_raw[1, j] == "nd") res_raw[1, j] <- "na" - } - } - res_raw[res_raw == "na"] <- NA - - not_nd_na <- function(value) !(grepl("nd", value) | is.na(value)) - - for (i in 1:nrow(res_raw)) { - for (j in 1:ncol(res_raw)) { - if (!is.na(res_raw[i, j]) && res_raw[i, j] == "nd") { - if (i > 1) { # check earlier sample in same layer - if (not_nd_na(res_raw[i - 1, j])) res_raw[i, j] <- "nda" - } - if (i < nrow(res_raw)) { # check later sample - if (not_nd_na(res_raw[i + 1, j])) res_raw[i, j] <- "nda" - } - if (j > 1) { # check above sample at the same time - if (not_nd_na(res_raw[i, j - 1])) res_raw[i, j] <- "nda" - } - if (j < ncol(res_raw)) { # check sample below at the same time - if (not_nd_na(res_raw[i, j + 1])) res_raw[i, j] <- "nda" - } - } - } - } - res_raw[res_raw == "nda"] <- nda - res_raw[res_raw == "nd"] <- NA - - result <- as.numeric(res_raw) - dim(result) <- dim(res_raw) - dimnames(result) <- dimnames(res_raw) - if (was_vector) result <- as.vector(result) - return(result) -} - -#' @describeIn set_nd_nq Set non-detects in residue time series according to FOCUS rules -#' @param set_first_sample_nd Should the first sample be set to "first_sample_nd_value" -#' in case it is a non-detection? -#' @param first_sample_nd_value Value to be used for the first sample if it is a non-detection -#' @param ignore_below_loq_after_first_nd Should we ignore values below the LOQ after the first -#' non-detection that occurs after the quantified values? -#' @export -set_nd_nq_focus <- function(res_raw, lod, loq = NA, - set_first_sample_nd = TRUE, first_sample_nd_value = 0, - ignore_below_loq_after_first_nd = TRUE) -{ - - if (!is.vector(res_raw)) stop("FOCUS rules are only specified for one-dimensional time series") - - if (ignore_below_loq_after_first_nd & is.na(loq)) { - stop("You need to specify an LOQ") - } - - n <- length(res_raw) - if (ignore_below_loq_after_first_nd) { - for (i in 3:n) { - if (!res_raw[i - 2] %in% c("na", "nd")) { - if (res_raw[i - 1] == "nd") { - res_remaining <- res_raw[i:n] - res_remaining_unquantified <- ifelse(res_remaining == "na", TRUE, - ifelse(res_remaining == "nd", TRUE, - ifelse(res_remaining == "nq", TRUE, - ifelse(suppressWarnings(as.numeric(res_remaining)) < loq, TRUE, FALSE)))) - res_remaining_numeric <- suppressWarnings(as.numeric(res_remaining)) - res_remaining_below_loq <- ifelse(res_remaining == "nq", TRUE, - ifelse(!is.na(res_remaining_numeric) & res_remaining_numeric < loq, TRUE, FALSE)) - if (all(res_remaining_unquantified)) { - res_raw[i:n] <- ifelse(res_remaining_below_loq, "nd", res_remaining) - } - } - } - } - } - - result <- set_nd_nq(res_raw, lod = lod, loq = loq) - - if (set_first_sample_nd) { - if (res_raw[1] == "nd") result[1] <- first_sample_nd_value - } - - return(result) -} @@ -12,5 +12,5 @@ Removed empty directory ‘pfm/inst/testdata/SwashProjects’ File(s) containing such objects: ‘pfm/data/EFSA_GW_interception_2014.RData’ ‘pfm/data/EFSA_washoff_2017.RData’ -* building ‘pfm_0.5.8.tar.gz’ +* building ‘pfm_0.5.9.tar.gz’ diff --git a/man/PEC_sw_focus.Rd b/man/PEC_sw_focus.Rd index 3ad1ad0..f23423b 100644 --- a/man/PEC_sw_focus.Rd +++ b/man/PEC_sw_focus.Rd @@ -26,7 +26,7 @@ PEC_sw_focus( } \arguments{ \item{parent}{A list containing substance specific parameters, e.g. -conveniently generated by \code{\link{chent_focus_sw}}.} +conveniently generated by [chent_focus_sw].} \item{rate}{The application rate in g/ha. Overriden when applications are given explicitly} @@ -38,20 +38,20 @@ applications are given explicitly} \item{comment}{A comment for the input file} \item{met}{A list containing metabolite specific parameters. e.g. -conveniently generated by \code{\link{chent_focus_sw}}. If not NULL, +conveniently generated by [chent_focus_sw]. If not NULL, the PEC is calculated for this compound, not the parent.} \item{f_drift}{The fraction of the application rate reaching the waterbody via drift. If NA, this is derived from the scenario name and the number of applications via the drift data defined by the -\code{\link{FOCUS_Step_12_scenarios}}} +[FOCUS_Step_12_scenarios]} \item{f_rd}{The fraction of the amount applied reaching the waterbody via runoff/drainage. At Step 1, it is assumed to be 10%, be it the parent or a metabolite} \item{scenario}{The name of the scenario. Must be one of the scenario -names given in \code{\link{FOCUS_Step_12_scenarios}}} +names given in [FOCUS_Step_12_scenarios]} \item{region}{'n' for Northern Europe or 's' for Southern Europe. If NA, only Step 1 PECsw are calculated} @@ -101,7 +101,7 @@ PEC_sw_focus(dummy_1, 3000, f_drift = 0, overwrite = TRUE, append = FALSE) # Metabolite new_dummy <- chent_focus_sw("New Dummy", mw = 250, Koc = 100) -M1 <- chent_focus_sw("M1", mw = 100, cwsat = 100, DT50_ws = 100, Koc = 50, +M1 <- chent_focus_sw("M1", mw = 100, cwsat = 100, DT50_ws = 100, Koc = 50, max_ws = 0, max_soil = 0.5) PEC_sw_focus(new_dummy, 1000, scenario = "cereals, winter", met = M1) } diff --git a/man/TOXSWA_cwa.Rd b/man/TOXSWA_cwa.Rd index 3daa1d0..de83ec2 100644 --- a/man/TOXSWA_cwa.Rd +++ b/man/TOXSWA_cwa.Rd @@ -49,16 +49,16 @@ for the requested moving window sizes in days.} \section{Methods}{ \subsection{Public methods}{ \itemize{ -\item \href{#method-new}{\code{TOXSWA_cwa$new()}} -\item \href{#method-moving_windows}{\code{TOXSWA_cwa$moving_windows()}} -\item \href{#method-get_events}{\code{TOXSWA_cwa$get_events()}} -\item \href{#method-print}{\code{TOXSWA_cwa$print()}} -\item \href{#method-clone}{\code{TOXSWA_cwa$clone()}} +\item \href{#method-TOXSWA_cwa-new}{\code{TOXSWA_cwa$new()}} +\item \href{#method-TOXSWA_cwa-moving_windows}{\code{TOXSWA_cwa$moving_windows()}} +\item \href{#method-TOXSWA_cwa-get_events}{\code{TOXSWA_cwa$get_events()}} +\item \href{#method-TOXSWA_cwa-print}{\code{TOXSWA_cwa$print()}} +\item \href{#method-TOXSWA_cwa-clone}{\code{TOXSWA_cwa$clone()}} } } \if{html}{\out{<hr>}} -\if{html}{\out{<a id="method-new"></a>}} -\if{latex}{\out{\hypertarget{method-new}{}}} +\if{html}{\out{<a id="method-TOXSWA_cwa-new"></a>}} +\if{latex}{\out{\hypertarget{method-TOXSWA_cwa-new}{}}} \subsection{Method \code{new()}}{ Create a TOXSWA_cwa object from a file \subsection{Usage}{ @@ -91,8 +91,8 @@ Create a TOXSWA_cwa object from a file } } \if{html}{\out{<hr>}} -\if{html}{\out{<a id="method-moving_windows"></a>}} -\if{latex}{\out{\hypertarget{method-moving_windows}{}}} +\if{html}{\out{<a id="method-TOXSWA_cwa-moving_windows"></a>}} +\if{latex}{\out{\hypertarget{method-TOXSWA_cwa-moving_windows}{}}} \subsection{Method \code{moving_windows()}}{ Add to the `windows` field described above. \subsection{Usage}{ @@ -111,8 +111,8 @@ suspended matter will be used.} } } \if{html}{\out{<hr>}} -\if{html}{\out{<a id="method-get_events"></a>}} -\if{latex}{\out{\hypertarget{method-get_events}{}}} +\if{html}{\out{<a id="method-TOXSWA_cwa-get_events"></a>}} +\if{latex}{\out{\hypertarget{method-TOXSWA_cwa-get_events}{}}} \subsection{Method \code{get_events()}}{ Populate a datataframe with event information for the specified threshold value. The resulting dataframe is stored in the `events` @@ -133,8 +133,8 @@ suspended matter will be used.} } } \if{html}{\out{<hr>}} -\if{html}{\out{<a id="method-print"></a>}} -\if{latex}{\out{\hypertarget{method-print}{}}} +\if{html}{\out{<a id="method-TOXSWA_cwa-print"></a>}} +\if{latex}{\out{\hypertarget{method-TOXSWA_cwa-print}{}}} \subsection{Method \code{print()}}{ Print a `TOXSWA_cwa` object \subsection{Usage}{ @@ -143,8 +143,8 @@ Print a `TOXSWA_cwa` object } \if{html}{\out{<hr>}} -\if{html}{\out{<a id="method-clone"></a>}} -\if{latex}{\out{\hypertarget{method-clone}{}}} +\if{html}{\out{<a id="method-TOXSWA_cwa-clone"></a>}} +\if{latex}{\out{\hypertarget{method-TOXSWA_cwa-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ diff --git a/man/reexports.Rd b/man/reexports.Rd new file mode 100644 index 0000000..4ae7190 --- /dev/null +++ b/man/reexports.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reexports.R +\docType{import} +\name{reexports} +\alias{reexports} +\alias{set_nd_nq} +\alias{set_nd_nq_focus} +\title{Objects exported from other packages} +\keyword{internal} +\description{ +These objects are imported from other packages. Follow the links +below to see their documentation. + +\describe{ + \item{mkin}{\code{\link[mkin]{set_nd_nq}}, \code{\link[mkin:set_nd_nq]{set_nd_nq_focus}}} +}} + diff --git a/man/set_nd_nq.Rd b/man/set_nd_nq.Rd deleted file mode 100644 index 7135d0d..0000000 --- a/man/set_nd_nq.Rd +++ /dev/null @@ -1,103 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/set_nd_nq.R -\name{set_nd_nq} -\alias{set_nd_nq} -\alias{set_nd_nq_focus} -\title{Set non-detects and unquantified values in residue series without replicates} -\usage{ -set_nd_nq(res_raw, lod, loq = NA, time_zero_presence = FALSE) - -set_nd_nq_focus( - res_raw, - lod, - loq = NA, - set_first_sample_nd = TRUE, - first_sample_nd_value = 0, - ignore_below_loq_after_first_nd = TRUE -) -} -\arguments{ -\item{res_raw}{Character vector of a residue time series, or matrix of -residue values with rows representing depth profiles for a specific sampling -time, and columns representing time series of residues at the same depth. -Values below the limit of detection (lod) have to be coded as "nd", values -between the limit of detection and the limit of quantification, if any, have -to be coded as "nq". Samples not analysed have to be coded as "na". All -values that are not "na", "nd" or "nq" have to be coercible to numeric} - -\item{lod}{Limit of detection (numeric)} - -\item{loq}{Limit of quantification(numeric). Must be specified if the FOCUS rule to -stop after the first non-detection is to be applied} - -\item{time_zero_presence}{Do we assume that residues occur at time zero? -This only affects samples from the first sampling time that have been -reported as "nd" (not detected).} - -\item{set_first_sample_nd}{Should the first sample be set to "first_sample_nd_value" -in case it is a non-detection?} - -\item{first_sample_nd_value}{Value to be used for the first sample if it is a non-detection} - -\item{ignore_below_loq_after_first_nd}{Should we ignore values below the LOQ after the first -non-detection that occurs after the quantified values?} -} -\value{ -A numeric vector, if a vector was supplied, or a numeric matrix otherwise -} -\description{ -This function automates replacing unquantified values in residue time and -depth series. For time series, the function performs part of the residue -processing proposed in the FOCUS kinetics guidance for parent compounds -and metabolites. For two-dimensional residue series over time and depth, -it automates the proposal of Boesten et al (2015). -} -\section{Functions}{ -\itemize{ -\item \code{set_nd_nq_focus}: Set non-detects in residue time series according to FOCUS rules -}} - -\examples{ -# FOCUS (2014) p. 75/76 and 131/132 -parent_1 <- c(.12, .09, .05, .03, "nd", "nd", "nd", "nd", "nd", "nd") -set_nd_nq(parent_1, 0.02) -parent_2 <- c(.12, .09, .05, .03, "nd", "nd", .03, "nd", "nd", "nd") -set_nd_nq(parent_2, 0.02) -set_nd_nq_focus(parent_2, 0.02, loq = 0.05) -parent_3 <- c(.12, .09, .05, .03, "nd", "nd", .06, "nd", "nd", "nd") -set_nd_nq(parent_3, 0.02) -set_nd_nq_focus(parent_3, 0.02, loq = 0.05) -metabolite <- c("nd", "nd", "nd", 0.03, 0.06, 0.10, 0.11, 0.10, 0.09, 0.05, 0.03, "nd", "nd") -set_nd_nq(metabolite, 0.02) -set_nd_nq_focus(metabolite, 0.02, 0.05) -# -# Boesten et al. (2015), p. 57/58 -table_8 <- matrix( - c(10, 10, rep("nd", 4), - 10, 10, rep("nq", 2), rep("nd", 2), - 10, 10, 10, "nq", "nd", "nd", - "nq", 10, "nq", rep("nd", 3), - "nd", "nq", "nq", rep("nd", 3), - rep("nd", 6), rep("nd", 6)), - ncol = 6, byrow = TRUE) -set_nd_nq(table_8, 0.5, 1.5, time_zero_presence = TRUE) -table_10 <- matrix( - c(10, 10, rep("nd", 4), - 10, 10, rep("nd", 4), - 10, 10, 10, rep("nd", 3), - "nd", 10, rep("nd", 4), - rep("nd", 18)), - ncol = 6, byrow = TRUE) -set_nd_nq(table_10, 0.5, time_zero_presence = TRUE) -} -\references{ -Boesten, J. J. T. I., van der Linden, A. M. A., Beltman, W. H. -J. and Pol, J. W. (2015). Leaching of plant protection products and their -transformation products; Proposals for improving the assessment of leaching -to groundwater in the Netherlands — Version 2. Alterra report 2630, Alterra -Wageningen UR (University & Research centre) - -FOCUS (2014) Generic Guidance for Estimating Persistence and Degradation - Kinetics from Environmental Fate Studies on Pesticides in EU Registration, Version 1.1, - 18 December 2014, p. 251 -} @@ -1,23 +1,18 @@ -ℹ Loading pfm -Loading required package: R6 -Loading required package: mkin -Loading required package: parallel ℹ Testing pfm ✔ | F W S OK | Context ✔ | 7 | Exposit calculations [0.1s] ✔ | 6 | Geometric mean calculation -✔ | 1 | Check max_twa for parent mkinfit models against analytical solutions [0.8s] +✔ | 1 | Check max_twa for parent mkinfit models against analytical solutions [0.9s] ✔ | 1 | Simple PEC sediment calculations ✔ | 17 | Simple PEC soil calculations [0.2s] ✔ | 6 | Simple PEC surface water calculations with drift entry -✔ | 11 | Processing of residue series ✔ | 1 | Actual and time weighted average concentrations for SFO kinetics -✔ | 9 | FOCUS Step 1 calculations [0.1s] +✔ | 9 | FOCUS Step 1 calculations [0.2s] ✔ | 8 | FOCUS Steps 12 input files -✔ | 7 | Read and analyse TOXSWA cwa files [5.8s] +✔ | 7 | Read and analyse TOXSWA cwa files [6.1s] ✔ | 12 | UK drainage PEC calculations ══ Results ═════════════════════════════════════════════════════════════════════════════════════════ -Duration: 7.3 s +Duration: 7.6 s -[ FAIL 0 | WARN 0 | SKIP 0 | PASS 86 ] +[ FAIL 0 | WARN 0 | SKIP 0 | PASS 75 ] diff --git a/tests/testthat/test_set_nd.R b/tests/testthat/test_set_nd.R deleted file mode 100644 index 232e7c6..0000000 --- a/tests/testthat/test_set_nd.R +++ /dev/null @@ -1,86 +0,0 @@ -context("Processing of residue series") - -# FOCUS (2014) page 76 (parent) and page 132 (metabolite) - -parent_1 <- c(.12, .09, .05, .03, "nd", "nd", "nd", "nd", "nd", "nd") -parent_2 <- c(.12, .09, .05, .03, "nd", "nd", .03, "nd", "nd", "nd") -parent_3 <- c(.12, .09, .05, .03, "nd", "nd", .06, "nd", "nd", "nd") -metabolite <- c("nd", "nd", "nd", 0.03, 0.06, 0.10, 0.11, 0.10, 0.09, 0.05, 0.03, "nd", "nd") - -test_that("Simple residue series are processed as intended", { - - expect_equal(set_nd_nq(parent_1, 0.02), - c(.12, .09, .05, .03, .01, rep(NA, 5))) - - expect_equal(set_nd_nq(parent_2, 0.02, loq = 0.05), - c(.12, .09, .05, .03, .01, .01, .03, .01, NA, NA)) - - expect_equal(set_nd_nq(metabolite, 0.02, loq = 0.05), - c(NA, NA, .01, .03, .06, .1, .11, .1, .09, .05, .03, .01, NA)) - - expect_equal(set_nd_nq(c("nd", 1, 0.2, "nd"), 0.1), - c(NA, 1, 0.2, 0.05)) - -}) - -test_that("Simple residue series are processed as in the FOCUS guidance", { - - # Parent 1 - expect_error(set_nd_nq_focus(parent_1, 0.02), - "You need to specify an LOQ") - expect_equal(set_nd_nq_focus(parent_1, 0.02, 0.05), - c(.12, .09, .05, .03, .01, rep(NA, 5))) - - # Parent 2 - expect_equal(set_nd_nq_focus(parent_2, 0.02, loq = 0.05), - c(.12, .09, .05, .03, .01, rep(NA, 5))) - - # Parent 3 - expect_equal(set_nd_nq_focus(parent_3, 0.02, loq = 0.05), - c(.12, .09, .05, .03, .01, .01, .06, .01, NA, NA)) - - # Metabolite - expect_equal(set_nd_nq_focus(metabolite, 0.02, loq = 0.05), - c(0, NA, .01, .03, .06, .1, .11, .1, .09, .05, .03, .01, NA)) - -}) - -test_that("Examples Boesten et al. (2015, p. 57/58) are correctly processed", { - table_8 <- matrix( - c(10, 10, rep("nd", 4), - 10, 10, rep("nq", 2), rep("nd", 2), - 10, 10, 10, "nq", "nd", "nd", - "nq", 10, "nq", rep("nd", 3), - "nd", "nq", "nq", rep("nd", 3), - rep("nd", 6), rep("nd", 6)), - ncol = 6, byrow = TRUE) - table_8_processed <- set_nd_nq(table_8, 0.5, 1.5, time_zero_presence = TRUE) - table_9 <- matrix( - c(10, 10, 0.25, 0.25, NA, NA, - 10, 10, 1, 1, 0.25, NA, - 10, 10, 10, 1, 0.25, NA, - 1, 10, 1, 0.25, NA, NA, - 0.25, 1, 1, 0.25, NA, NA, - NA, 0.25, 0.25, NA, NA, NA, - rep(NA, 6)), - ncol = 6, byrow = TRUE) - expect_equal(table_8_processed, table_9) - - table_10 <- matrix( - c(10, 10, rep("nd", 4), - 10, 10, rep("nd", 4), - 10, 10, 10, rep("nd", 3), - "nd", 10, rep("nd", 4), - rep("nd", 18)), - ncol = 6, byrow = TRUE) - table_10_processed <- set_nd_nq(table_10, 0.5, time_zero_presence = TRUE) - table_11 <- matrix( - c(10, 10, 0.25, rep(NA, 3), - 10, 10, 0.25, rep(NA, 3), - 10, 10, 10, 0.25, NA, NA, - 0.25, 10, 0.25, rep(NA, 3), - NA, 0.25, rep(NA, 4), - rep(NA, 12)), - ncol = 6, byrow = TRUE) - expect_equal(table_10_processed, table_11) -}) |