From d81550d0cccae824cc748de48e7fd50ea8d8033a Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 16 Apr 2020 18:02:18 +0200 Subject: Make na.rm = FALSE the default for geomean() This makes more sense and is in line with mean() from base R. Adapt tests and update docs. --- ChangeLog | 6 ++ DESCRIPTION | 4 +- R/geomean.R | 11 +-- docs/index.html | 2 +- docs/reference/FOCUS_Step_12_scenarios.html | 14 ++-- docs/reference/FOMC_actual_twa.html | 22 +++--- docs/reference/GUS.html | 32 +++++---- docs/reference/PEC_soil.html | 51 +++++++------ docs/reference/PEC_sw_drainage_UK.html | 29 ++++---- docs/reference/PEC_sw_drift.html | 30 ++++---- docs/reference/PEC_sw_exposit_drainage.html | 34 ++++----- docs/reference/PEC_sw_exposit_runoff.html | 33 ++++----- docs/reference/PEC_sw_focus.html | 42 ++++++----- docs/reference/PEC_sw_sed.html | 27 +++---- docs/reference/SFO_actual_twa.html | 18 ++--- docs/reference/TOXSWA_cwa.html | 97 ++++++++++++++++++------- docs/reference/chent_focus_sw.html | 31 ++++---- docs/reference/endpoint.html | 62 +++++++++------- docs/reference/geomean.html | 29 ++++---- docs/reference/one_box.html | 21 +++--- docs/reference/pfm_degradation.html | 24 ++++--- docs/reference/plot.TOXSWA_cwa.html | 29 +++++--- docs/reference/plot.one_box-3.png | Bin 37287 -> 37285 bytes docs/reference/plot.one_box.html | 28 ++++---- docs/reference/read.TOXSWA_cwa.html | 28 ++++---- docs/reference/sawtooth-2.png | Bin 37287 -> 37285 bytes docs/reference/sawtooth.html | 21 +++--- docs/reference/set_nd_nq.html | 10 ++- man/FOCUS_Step_12_scenarios.Rd | 4 +- man/FOMC_actual_twa.Rd | 7 +- man/GUS.Rd | 14 ++-- man/PEC_soil.Rd | 30 ++++++-- man/PEC_sw_drainage_UK.Rd | 12 +++- man/PEC_sw_drift.Rd | 15 ++-- man/PEC_sw_exposit_drainage.Rd | 15 ++-- man/PEC_sw_exposit_runoff.Rd | 14 +++- man/PEC_sw_focus.Rd | 25 +++++-- man/PEC_sw_sed.Rd | 12 +++- man/SFO_actual_twa.Rd | 3 +- man/TOXSWA_cwa.Rd | 106 ++++++++++++++++++++++------ man/chent_focus_sw.Rd | 15 +++- man/endpoint.Rd | 40 +++++++---- man/geomean.Rd | 7 +- man/one_box.Rd | 6 +- man/pfm_degradation.Rd | 11 ++- man/plot.TOXSWA_cwa.Rd | 16 +++-- man/plot.one_box.Rd | 13 +++- man/read.TOXSWA_cwa.Rd | 13 +++- man/sawtooth.Rd | 8 ++- man/set_nd_nq.Rd | 10 ++- tests/testthat/test_geomean.R | 4 +- 51 files changed, 723 insertions(+), 412 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24ec4e0..fcab6a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +commit 4bc95b3e4aae22e4052e0a4c905a9227c909e2cd +Author: Johannes Ranke +Date: 2020-02-19 07:49:08 +0100 + + Check in last build log + commit 00e177fdf6929058fd26c3086ae159462ae0a456 Author: Johannes Ranke Date: 2019-10-23 16:18:24 +0200 diff --git a/DESCRIPTION b/DESCRIPTION index 9487deb..4d471dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: pfm Type: Package Title: Utilities for Pesticide Fate Modelling Version: 0.5.7 -Date: 2019-11-20 +Date: 2020-04-16 Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0003-4371-6538")) @@ -32,4 +32,4 @@ LazyLoad: yes LazyData: yes Encoding: UTF-8 URL: https://pkdown.jrwb.de/pfm -RoxygenNote: 6.1.1 +RoxygenNote: 7.0.2 diff --git a/R/geomean.R b/R/geomean.R index 626829b..04328c8 100644 --- a/R/geomean.R +++ b/R/geomean.R @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Johannes Ranke +# Copyright (C) 2015,2020 Johannes Ranke # Contact: jranke@uni-bremen.de # This file is part of the R package pfm @@ -19,8 +19,9 @@ #' #' Based on some posts in a thread on Stackoverflow #' \url{http://stackoverflow.com/questions/2602583/geometric-mean-is-there-a-built-in} -#' This function checks for negative values, removes NA values per default and -#' returns 0 if at least one element of the vector is 0. +#' This function returns NA if NA values are present and na.rm = FALSE +#' (default). If negative values are present, it gives an error message. +#' If at least one element of the vector is 0, it returns 0. #' #' @param x Vector of numbers #' @param na.rm Should NA values be omitted? @@ -31,8 +32,8 @@ #' geomean(c(1, 3, 9)) #' geomean(c(1, 3, NA, 9)) #' \dontrun{geomean(c(1, -3, 9)) # returns an error} -geomean = function(x, na.rm = TRUE){ - if (any(is.na(x)) & na.rm == FALSE) stop("Removal of NA values was not requested") +geomean = function(x, na.rm = FALSE) { + if (any(is.na(x)) & na.rm == FALSE) return(NA) if (any(x < 0, na.rm = na.rm)) stop("Only defined for positive numbers") exp(mean(log(x), na.rm = na.rm)) } diff --git a/docs/index.html b/docs/index.html index 23000f1..2e42649 100644 --- a/docs/index.html +++ b/docs/index.html @@ -75,7 +75,7 @@ install.packages("pfm")

Alternatively you can install the package using the devtools package. Using quick = TRUE skips docs, multiple-architecture builds, demos, and vignettes.

library(devtools)
-install_github("jranke/pfm", quick = TRUE)
+install_github("jranke/pfm", quick = TRUE)

diff --git a/docs/reference/FOCUS_Step_12_scenarios.html b/docs/reference/FOCUS_Step_12_scenarios.html index 4eed02f..77045f1 100644 --- a/docs/reference/FOCUS_Step_12_scenarios.html +++ b/docs/reference/FOCUS_Step_12_scenarios.html @@ -8,11 +8,13 @@ Step 1/2 scenario data as distributed with the FOCUS Step 1/2 calculator — FOCUS_Step_12_scenarios • pfm + + @@ -32,14 +34,15 @@ - + + @@ -83,7 +86,6 @@ The text file is not included in the package as its licence is not clear." /> Reference - @@ -105,20 +107,18 @@ The text file is not included in the package as its licence is not clear." />

-

The data were extracted from the scenario.txt file using the R code shown below. The text file is not included in the package as its licence is not clear.

-
- + +

Format

A list containing the scenario names in a character vector called 'names', the drift percentiles in a matrix called 'drift', interception percentages in a matrix called 'interception' and the runoff/drainage percentages for Step 2 calculations in a matrix called 'rd'.

-

Examples

@@ -295,9 +295,7 @@ The text file is not included in the package as its licence is not clear.

-

Actual and maximum moving window time average concentrations for FOMC kinetics

-
-
FOMC_actual_twa(alpha = 1.0001, beta = 10, times = c(0, 1, 2, 4, 7,
-  14, 21, 28, 42, 50, 100))
- +
FOMC_actual_twa(
+  alpha = 1.0001,
+  beta = 10,
+  times = c(0, 1, 2, 4, 7, 14, 21, 28, 42, 50, 100)
+)
+

Arguments

@@ -128,13 +131,12 @@

The output times, and window sizes for time weighted average concentrations

- +

Source

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

-

Examples

FOMC_actual_twa(alpha = 1.0001, beta = 10)
#> actual twa @@ -154,9 +156,7 @@

Contents

diff --git a/docs/reference/GUS.html b/docs/reference/GUS.html index b44c120..e371c1a 100644 --- a/docs/reference/GUS.html +++ b/docs/reference/GUS.html @@ -8,11 +8,13 @@ Groundwater ubiquity score based on Gustafson (1989) — GUS • pfm + + @@ -32,8 +34,8 @@ - + @@ -41,6 +43,7 @@ $$GUS = \log_{10} DT50_{soil} (4 - \log_{10} K_{oc})$$" /> + @@ -84,7 +87,6 @@ $$GUS = \log_{10} DT50_{soil} (4 - \log_{10} K_{oc})$$" /> Reference - @@ -106,11 +108,9 @@ $$GUS = \log_{10} DT50_{soil} (4 - \log_{10} K_{oc})$$" />
-

The groundwater ubiquity score GUS is calculated according to the following equation $$GUS = \log_{10} DT50_{soil} (4 - \log_{10} K_{oc})$$

-
GUS(...)
@@ -119,14 +119,20 @@ $$GUS = \log_{10} DT50_{soil} (4 - \log_{10} K_{oc})$$

GUS(DT50, Koc, ...) # S3 method for chent -GUS(chent, degradation_value = "DT50ref", - lab_field = "laboratory", redox = "aerobic", - sorption_value = "Kfoc", degradation_aggregator = geomean, - sorption_aggregator = geomean, ...) +GUS( + chent, + degradation_value = "DT50ref", + lab_field = "laboratory", + redox = "aerobic", + sorption_value = "Kfoc", + degradation_aggregator = geomean, + sorption_aggregator = geomean, + ... +) # S3 method for GUS_result print(x, ..., digits = 1)
- +

Arguments

@@ -198,29 +204,25 @@ be Koc values at a concentration of 1 mg/L in the water phase.

The number of digits used in the print method

- +

Value

A list with the DT50 and Koc used as well as the resulting score of class GUS_result

-

References

Gustafson, David I. (1989) Groundwater ubiquity score: a simple method for assessing pesticide leachability. Environmental toxicology and chemistry 8(4) 339–57.

-
-

This is a basic calculation of a contaminant concentration in bulk soil based on complete, instantaneous mixing. If an interval is given, an attempt is made at calculating a long term maximum concentration using the concepts layed out in the PPR panel opinion (EFSA PPR panel 2012 and in the EFSA guidance on PEC soil calculations (EFSA, 2015, 2017).

-
-
PEC_soil(rate, rate_units = "g/ha", interception = 0,
-  mixing_depth = 5, PEC_units = "mg/kg", PEC_pw_units = "mg/L",
-  interval = NA, n_periods = Inf, tillage_depth = 20,
-  leaching_depth = tillage_depth, crop = "annual",
-  cultivation = FALSE, chent = NA, DT50 = NA, FOMC = NA,
-  Koc = NA, Kom = Koc/1.724, t_avg = 0, t_act = NULL,
+    
PEC_soil(
+  rate,
+  rate_units = "g/ha",
+  interception = 0,
+  mixing_depth = 5,
+  PEC_units = "mg/kg",
+  PEC_pw_units = "mg/L",
+  interval = NA,
+  n_periods = Inf,
+  tillage_depth = 20,
+  leaching_depth = tillage_depth,
+  crop = "annual",
+  cultivation = FALSE,
+  chent = NA,
+  DT50 = NA,
+  FOMC = NA,
+  Koc = NA,
+  Kom = Koc/1.724,
+  t_avg = 0,
+  t_act = NULL,
   scenarios = c("default", "EFSA_2017", "EFSA_2015"),
-  leaching = scenarios == "EFSA_2017", porewater = FALSE)
- + leaching = scenarios == "EFSA_2017", + porewater = FALSE +)
+

Arguments

@@ -245,11 +261,10 @@ soil concentrations? Based on equation (7) given in the PPR panel opinion p. 13).

- +

Value

The predicted concentration in soil

-

Details

This assumes that the complete load to soil during the time specified by @@ -258,7 +273,6 @@ opinion cited below (EFSA PPR panel 2012), only temperature correction using the Arrhenius equation is performed.

Total soil and porewater PEC values for the scenarios as defined in the EFSA guidance (2017, p. 14/15) can easily be calculated.

-

Note

While time weighted average (TWA) concentrations given in the examples @@ -275,7 +289,6 @@ from 2017 (p. 92).

e.g. in the EFSA scenarios, the DT50 for groundwater modelling (destination 'PECgw') is taken from the chent object, otherwise the DT50 with destination 'PECsoil'.

-

References

EFSA Panel on Plant Protection Products and their Residues (2012) @@ -293,7 +306,6 @@ from 2017 (p. 92).

protection products and transformation products of these active substances in soil. EFSA Journal 13(4) 4093 doi:10.2903/j.efsa.2015.4093

-

Examples

PEC_soil(100, interception = 0.25)
#> scenario @@ -334,15 +346,10 @@ from 2017 (p. 92).

Contents

diff --git a/docs/reference/PEC_sw_drainage_UK.html b/docs/reference/PEC_sw_drainage_UK.html index f641773..bdcf5af 100644 --- a/docs/reference/PEC_sw_drainage_UK.html +++ b/docs/reference/PEC_sw_drainage_UK.html @@ -8,11 +8,13 @@ Calculate initial predicted environmental concentrations in surface water due to drainage using the UK method — PEC_sw_drainage_UK • pfm + + @@ -32,14 +34,15 @@ - + + @@ -83,7 +86,6 @@ published on the CRC website" /> Reference - @@ -105,16 +107,20 @@ published on the CRC website" />
-

This implements the method specified in the UK data requirements handbook and was checked against the spreadsheet published on the CRC website

-
-
PEC_sw_drainage_UK(rate, interception = 0, Koc,
-  latest_application = NULL, soil_DT50 = NULL, model = NULL,
-  model_parms = NULL)
- +
PEC_sw_drainage_UK(
+  rate,
+  interception = 0,
+  Koc,
+  latest_application = NULL,
+  soil_DT50 = NULL,
+  model = NULL,
+  model_parms = NULL
+)
+

Arguments

@@ -148,11 +154,10 @@ published on the CRC website

A named numeric vector containing the model parameters

- +

Value

The predicted concentration in surface water in µg/L

-

References

HSE's Chemicals Regulation Division (CRD) Active substance @@ -162,7 +167,6 @@ published on the CRC website

Drainage PECs Version 1.0 (2015) Spreadsheet published at https://www.hse.gov.uk/pesticides/topics/pesticide-approvals/pesticides-registration/data-requirements-handbook/fate/pec-tools-2015/PEC%20sw-sed%20(drainage).xlsx accessed 2019-09-27

-

Examples

PEC_sw_drainage_UK(150, Koc = 100)
#> [1] 8.076923
@@ -171,11 +175,8 @@ published on the CRC website

Contents

diff --git a/docs/reference/PEC_sw_drift.html b/docs/reference/PEC_sw_drift.html index 14ccf79..302ab0d 100644 --- a/docs/reference/PEC_sw_drift.html +++ b/docs/reference/PEC_sw_drift.html @@ -8,11 +8,13 @@ Calculate predicted environmental concentrations in surface water due to drift — PEC_sw_drift • pfm + + @@ -32,8 +34,8 @@ - + @@ -41,6 +43,7 @@ with input via spray drift." /> + @@ -84,7 +87,6 @@ with input via spray drift." /> Reference - @@ -106,18 +108,23 @@ with input via spray drift." />
-

This is a basic, vectorised form of a simple calculation of a contaminant concentration in surface water based on complete, instantaneous mixing with input via spray drift.

-
-
PEC_sw_drift(rate, applications = 1, water_depth = 30,
-  drift_percentages = NULL, drift_data = "JKI", crop = "Ackerbau",
-  distances = c(1, 5, 10, 20), rate_units = "g/ha",
-  PEC_units = "µg/L")
- +
PEC_sw_drift(
+  rate,
+  applications = 1,
+  water_depth = 30,
+  drift_percentages = NULL,
+  drift_data = "JKI",
+  crop = "Ackerbau",
+  distances = c(1, 5, 10, 20),
+  rate_units = "g/ha",
+  PEC_units = "µg/L"
+)
+

Arguments

@@ -159,11 +166,10 @@ with input via spray drift.

Requested units for the calculated PEC. Only µg/L currently supported

- +

Value

The predicted concentration in surface water

-

Examples

PEC_sw_drift(100)
#> 1 m 5 m 10 m 20 m @@ -173,9 +179,7 @@ with input via spray drift.

Contents

diff --git a/docs/reference/PEC_sw_exposit_drainage.html b/docs/reference/PEC_sw_exposit_drainage.html index 1c2deac..5bd1d80 100644 --- a/docs/reference/PEC_sw_exposit_drainage.html +++ b/docs/reference/PEC_sw_exposit_drainage.html @@ -8,11 +8,13 @@ Calculate PEC surface water due to drainage as in Exposit 3 — PEC_sw_exposit_drainage • pfm + + @@ -32,8 +34,8 @@ - + + @@ -88,7 +91,6 @@ details, see the discussion of the function arguments below." /> Reference - @@ -110,7 +112,6 @@ details, see the discussion of the function arguments below." />
-

This is a reimplementation of the calculation described in the Exposit 3.02 spreadsheet file, in the worksheet "Konzept Drainage". Although there are four groups of compounds ("Gefährdungsgruppen"), only one distinction is made in the @@ -118,14 +119,20 @@ calculations, between compounds with low mobility (group 1) and compounds with modest to high mobility (groups 2, 3 and 4). In this implementation, the group is derived only from the Koc, if not given explicitly. For details, see the discussion of the function arguments below.

-
-
PEC_sw_exposit_drainage(rate, interception = 0, Koc = NA,
-  mobility = c(NA, "low", "high"), DT50 = Inf, t_drainage = 3,
-  V_ditch = 30, V_drainage = c(spring = 10, autumn = 100),
-  dilution = 2)
- +
PEC_sw_exposit_drainage(
+  rate,
+  interception = 0,
+  Koc = NA,
+  mobility = c(NA, "low", "high"),
+  DT50 = Inf,
+  t_drainage = 3,
+  V_ditch = 30,
+  V_drainage = c(spring = 10, autumn = 100),
+  dilution = 2
+)
+

Arguments

@@ -168,12 +175,11 @@ autumn/winter/early spring.

The dilution factor

- +

Source

Excel 3.02 spreadsheet available from https://www.bvl.bund.de/DE/04_Pflanzenschutzmittel/03_Antragsteller/04_Zulassungsverfahren/07_Naturhaushalt/psm_naturhaush_node.html#doc1400590bodyText3

-

Value

A list containing the following components

@@ -184,11 +190,9 @@ autumn/winter/early spring.

-

See also

perc_runoff_exposit for runoff loss percentages and perc_runoff_reduction_exposit for runoff reduction percentages used

-

Examples

PEC_sw_exposit_drainage(500, Koc = 150)
#> $perc_drainage_total @@ -208,13 +212,9 @@ autumn/winter/early spring.

Contents

diff --git a/docs/reference/PEC_sw_exposit_runoff.html b/docs/reference/PEC_sw_exposit_runoff.html index 30ef975..81549e0 100644 --- a/docs/reference/PEC_sw_exposit_runoff.html +++ b/docs/reference/PEC_sw_exposit_runoff.html @@ -8,11 +8,13 @@ Calculate PEC surface water due to runoff and erosion as in Exposit 3 — PEC_sw_exposit_runoff • pfm + + @@ -32,14 +34,15 @@ - + + @@ -83,7 +86,6 @@ in the worksheet "Konzept Runoff"." /> Reference - @@ -105,16 +107,22 @@ in the worksheet "Konzept Runoff"." />
-

This is a reimplementation of the calculation described in the Exposit 3.02 spreadsheet file, in the worksheet "Konzept Runoff".

-
-
PEC_sw_exposit_runoff(rate, interception = 0, Koc, DT50 = Inf,
-  t_runoff = 3, exposit_reduction_version = c("3.02", "3.01a",
-  "3.01a2", "2.0"), V_ditch = 30, V_event = 100, dilution = 2)
- +
PEC_sw_exposit_runoff(
+  rate,
+  interception = 0,
+  Koc,
+  DT50 = Inf,
+  t_runoff = 3,
+  exposit_reduction_version = c("3.02", "3.01a", "3.01a2", "2.0"),
+  V_ditch = 30,
+  V_event = 100,
+  dilution = 2
+)
+

Arguments

@@ -159,12 +167,11 @@ and the bound fraction.

The dilution factor

- +

Source

Excel 3.02 spreadsheet available from https://www.bvl.bund.de/DE/04_Pflanzenschutzmittel/03_Antragsteller/04_Zulassungsverfahren/07_Naturhaushalt/psm_naturhaush_node.html#doc1400590bodyText3

-

Value

A list containing the following components

@@ -175,11 +182,9 @@ and the bound fraction.

-

See also

perc_runoff_exposit for runoff loss percentages and perc_runoff_reduction_exposit for runoff reduction percentages used

-

Examples

PEC_sw_exposit_runoff(500, Koc = 150)
#> $perc_runoff @@ -226,13 +231,9 @@ and the bound fraction.

Contents

diff --git a/docs/reference/PEC_sw_focus.html b/docs/reference/PEC_sw_focus.html index 1647b19..8242f6a 100644 --- a/docs/reference/PEC_sw_focus.html +++ b/docs/reference/PEC_sw_focus.html @@ -8,11 +8,13 @@ Calculate PEC surface water at FOCUS Step 1 — PEC_sw_focus • pfm + + @@ -32,8 +34,8 @@ - + + @@ -88,7 +91,6 @@ to be used with the FOCUS calculator." /> Reference - @@ -110,7 +112,6 @@ to be used with the FOCUS calculator." />
-

This is a reimplementation of the FOCUS Step 1 and 2 calculator version 3.2, authored by Michael Klein, in R. Note that results for multiple applications should be compared to the corresponding results for a @@ -118,16 +119,28 @@ single application. At current, this is not done automatically in this implementation. Only Step 1 PECs are calculated. However, input files are generated that are suitable as input also for Step 2 to be used with the FOCUS calculator.

-
-
PEC_sw_focus(parent, rate, n = 1, i = NA, comment = "", met = NULL,
-  f_drift = NA, f_rd = 0.1, scenario = FOCUS_Step_12_scenarios$names,
-  region = c("n", "s"), season = c(NA, "of", "mm", "js"),
-  interception = c("no interception", "minimal crop cover",
-  "average crop cover", "full canopy"), met_form_water = TRUE,
-  txt_file = "pesticide.txt", overwrite = FALSE, append = TRUE)
- +
PEC_sw_focus(
+  parent,
+  rate,
+  n = 1,
+  i = NA,
+  comment = "",
+  met = NULL,
+  f_drift = NA,
+  f_rd = 0.1,
+  scenario = FOCUS_Step_12_scenarios$names,
+  region = c("n", "s"),
+  season = c(NA, "of", "mm", "js"),
+  interception = c("no interception", "minimal crop cover", "average crop cover",
+    "full canopy"),
+  met_form_water = TRUE,
+  txt_file = "pesticide.txt",
+  overwrite = FALSE,
+  append = TRUE
+)
+

Arguments

@@ -214,7 +227,7 @@ should be written

Should the input text file be appended?

- +

Note

The formulas for input to the waterbody via runoff/drainage of the @@ -224,7 +237,6 @@ should be written

multiplying the application rate with the molar weight correction and the formation fraction in water/sediment systems.

Step 2 is not implemented.

-

References

FOCUS (2014) Generic guidance for Surface Water Scenarios (version 1.4). @@ -233,7 +245,6 @@ should be written

Website of the Steps 1 and 2 calculator at the Joint Research Center of the European Union: http://esdac.jrc.ec.europa.eu/projects/stepsonetwo

-

Examples

# Parent only @@ -337,11 +348,8 @@ should be written

Contents

diff --git a/docs/reference/PEC_sw_sed.html b/docs/reference/PEC_sw_sed.html index fe65d96..458eeb7 100644 --- a/docs/reference/PEC_sw_sed.html +++ b/docs/reference/PEC_sw_sed.html @@ -9,11 +9,13 @@ Calculate predicted environmental concentrations in sediment from surface water concentrations — PEC_sw_sed • pfm + + @@ -33,15 +35,16 @@ water concentrations — PEC_sw_sed • pfm + - + @@ -85,7 +88,6 @@ PEC calculator" /> Reference - @@ -108,16 +110,20 @@ water concentrations
-

The method 'percentage' is equivalent to what is used in the CRD spreadsheet PEC calculator

-
-
PEC_sw_sed(PEC_sw, percentage = 100, method = "percentage",
-  sediment_depth = 5, water_depth = 30, sediment_density = 1.3,
-  PEC_sed_units = c("µg/kg", "mg/kg"))
- +
PEC_sw_sed(
+  PEC_sw,
+  percentage = 100,
+  method = "percentage",
+  sediment_depth = 5,
+  water_depth = 30,
+  sediment_density = 1.3,
+  PEC_sed_units = c("µg/kg", "mg/kg")
+)
+

Arguments

@@ -152,11 +158,10 @@ g/cm3)

The units of the estimated sediment PEC value

- +

Value

The predicted concentration in sediment

-

Examples

PEC_sw_sed(PEC_sw_drift(100, distances = 1), percentage = 50)
#> 1 m @@ -166,9 +171,7 @@ g/cm3)

Contents

diff --git a/docs/reference/SFO_actual_twa.html b/docs/reference/SFO_actual_twa.html index 1f172c6..b5fa5da 100644 --- a/docs/reference/SFO_actual_twa.html +++ b/docs/reference/SFO_actual_twa.html @@ -8,11 +8,13 @@ Actual and maximum moving window time average concentrations for SFO kinetics — SFO_actual_twa • pfm + + @@ -32,13 +34,14 @@ - + + @@ -82,7 +85,6 @@ Reference - @@ -104,14 +106,11 @@
-

Actual and maximum moving window time average concentrations for SFO kinetics

-
-
SFO_actual_twa(DT50 = 1000, times = c(0, 1, 2, 4, 7, 14, 21, 28, 42,
-  50, 100))
- +
SFO_actual_twa(DT50 = 1000, times = c(0, 1, 2, 4, 7, 14, 21, 28, 42, 50, 100))
+

Arguments

@@ -124,13 +123,12 @@

The output times, and window sizes for time weighted average concentrations

- +

Source

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

-

Examples

SFO_actual_twa(10)
#> actual twa @@ -150,9 +148,7 @@

Contents

diff --git a/docs/reference/TOXSWA_cwa.html b/docs/reference/TOXSWA_cwa.html index 8939850..cedb023 100644 --- a/docs/reference/TOXSWA_cwa.html +++ b/docs/reference/TOXSWA_cwa.html @@ -8,11 +8,13 @@ R6 class for holding TOXSWA water concentration data and associated statistics — TOXSWA_cwa • pfm + + @@ -32,14 +34,15 @@ - + + @@ -83,7 +86,6 @@ Usually, an instance of this class will be generated by read.TOXSWA_cwa." /> Reference - @@ -105,23 +107,33 @@ Usually, an instance of this class will be generated by read.TOXSWA_cwa." />
-

An R6 class for holding TOXSWA water concentration (cwa) data and some associated statistics. Usually, an instance of this class will be generated by read.TOXSWA_cwa.

-
-
TOXSWA_cwa
- + +

Format

An R6Class generator object.

- -

Fields

+

Methods

+
get_events(threshold, total = FALSE)

Populate a datataframe with event information for the specified threshold value + in µg/L. If total = TRUE, the total concentration including the amount + adsorbed to suspended matter will be used. The resulting dataframe is stored in the + events field of the object.

+
moving_windows(windows, total = FALSE)

Add to the windows field described above. + Again, if total = TRUE, the total concentration including the amount + adsorbed to suspended matter will be used.

+ +
+ +

Public fields

+ +

filename

Length one character vector.

basedir

Length one character vector.

@@ -136,24 +148,62 @@ Usually, an instance of this class will be generated by -
get_events(threshold, total = FALSE)

Populate a datataframe with event information for the specified threshold value - in µg/L. If total = TRUE, the total concentration including the amount - adsorbed to suspended matter will be used. The resulting dataframe is stored in the - events field of the object.

-
moving_windows(windows, total = FALSE)

Add to the windows field described above. - Again, if total = TRUE, the total concentration including the amount - adsorbed to suspended matter will be used.

+
+


+

Method new()

+ +

Usage

+

TOXSWA_cwa$new(
+  filename,
+  basedir,
+  zipfile = NULL,
+  segment = "last",
+  substance = "parent",
+  total = FALSE
+)

+ +


+

Method moving_windows()

+ +

Usage

+

TOXSWA_cwa$moving_windows(windows, total = FALSE)

+ +


+

Method get_events()

+ +

Usage

+

TOXSWA_cwa$get_events(thresholds, total = FALSE)

+ +


+

Method print()

+ +

Usage

+

TOXSWA_cwa$print()

+ +


+

Method clone()

+

The objects of this class are cloneable with this method.

Usage

+

TOXSWA_cwa$clone(deep = FALSE)

+ +

Arguments

+

+
deep

Whether to make a deep clone.

+ +

-
-

Examples

H_sw_R1_stream <- read.TOXSWA_cwa("00003s_pa.cwa", @@ -192,13 +242,10 @@ for the requested moving window sizes in days.

-

Create a chemical compound object for FOCUS Step 1 calculations

-
-
chent_focus_sw(name, Koc, DT50_ws = NA, DT50_soil = NA,
-  DT50_water = NA, DT50_sediment = NA, cwsat = 1000, mw = NA,
-  max_soil = 1, max_ws = 1)
- +
chent_focus_sw(
+  name,
+  Koc,
+  DT50_ws = NA,
+  DT50_soil = NA,
+  DT50_water = NA,
+  DT50_sediment = NA,
+  cwsat = 1000,
+  mw = NA,
+  max_soil = 1,
+  max_ws = 1
+)
+

Arguments

@@ -159,20 +168,18 @@ in L/kg.

systems

- +

Value

A list with the substance specific properties

-
diff --git a/docs/reference/endpoint.html b/docs/reference/endpoint.html index 99e407c..39071ee 100644 --- a/docs/reference/endpoint.html +++ b/docs/reference/endpoint.html @@ -8,11 +8,13 @@ Retrieve endpoint information from the chyaml field of a chent object — endpoint • pfm + + @@ -32,8 +34,8 @@ - + + @@ -85,7 +88,6 @@ this function." /> Reference - @@ -107,32 +109,46 @@ this function." />
-

R6 class objects of class chent represent chemical entities and can hold a list of information loaded from a chemical yaml file in their chyaml field. Such information is extracted and optionally aggregated by this function.

-
-
endpoint(chent, medium = "soil", type = c("degradation", "sorption"),
-  lab_field = c(NA, "laboratory", "field"), redox = c(NA, "aerobic",
-  "anaerobic"), value = c("DT50ref", "Kfoc", "N"),
-  aggregator = geomean, raw = FALSE, signif = 3)
-
-soil_DT50(chent, aggregator = geomean, signif = 3,
-  lab_field = "laboratory", value = "DT50ref", redox = "aerobic",
-  raw = FALSE)
-
-soil_Kfoc(chent, aggregator = geomean, signif = 3, value = "Kfoc",
-  raw = FALSE)
+    
endpoint(
+  chent,
+  medium = "soil",
+  type = c("degradation", "sorption"),
+  lab_field = c(NA, "laboratory", "field"),
+  redox = c(NA, "aerobic", "anaerobic"),
+  value = c("DT50ref", "Kfoc", "N"),
+  aggregator = geomean,
+  raw = FALSE,
+  signif = 3
+)
+
+soil_DT50(
+  chent,
+  aggregator = geomean,
+  signif = 3,
+  lab_field = "laboratory",
+  value = "DT50ref",
+  redox = "aerobic",
+  raw = FALSE
+)
+
+soil_Kfoc(chent, aggregator = geomean, signif = 3, value = "Kfoc", raw = FALSE)
 
 soil_N(chent, aggregator = mean, signif = 3, raw = FALSE)
 
-soil_sorption(chent, values = c("Kfoc", "N"), aggregators = c(Kfoc =
-  geomean, Koc = geomean, N = mean), signif = c(Kfoc = 3, N = 3),
-  raw = FALSE)
- +soil_sorption( + chent, + values = c("Kfoc", "N"), + aggregators = c(Kfoc = geomean, Koc = geomean, N = mean), + signif = c(Kfoc = 3, N = 3), + raw = FALSE +)
+

Arguments

@@ -185,7 +201,7 @@ about precision?

A named vector of aggregator functions to be used

- +

Value

The result from applying the aggregator function to @@ -193,25 +209,21 @@ about precision?

given number of significant digits, or, if raw = TRUE, the values as a character value, retaining any implicit information on precision that may be present.

-

Details

The functions soil_* are functions to extract soil specific endpoints. For the Freundlich exponent, the capital letter N is used in order to facilitate dealing with such data in R. In pesticide fate modelling, this exponent is often called 1/n.

- diff --git a/docs/reference/geomean.html b/docs/reference/geomean.html index 469e12f..34befc3 100644 --- a/docs/reference/geomean.html +++ b/docs/reference/geomean.html @@ -8,11 +8,13 @@ Calculate the geometric mean — geomean • pfm + + @@ -32,16 +34,18 @@ - + +This function returns NA if NA values are present and na.rm = FALSE +(default). If negative values are present, it gives an error message. +If at least one element of the vector is 0, it returns 0." /> + @@ -85,7 +89,6 @@ returns 0 if at least one element of the vector is 0." /> Reference - @@ -107,16 +110,15 @@ returns 0 if at least one element of the vector is 0." />
-

Based on some posts in a thread on Stackoverflow http://stackoverflow.com/questions/2602583/geometric-mean-is-there-a-built-in -This function checks for negative values, removes NA values per default and -returns 0 if at least one element of the vector is 0.

- +This function returns NA if NA values are present and na.rm = FALSE +(default). If negative values are present, it gives an error message. +If at least one element of the vector is 0, it returns 0.

-
geomean(x, na.rm = TRUE)
- +
geomean(x, na.rm = FALSE)
+

Arguments

@@ -129,22 +131,19 @@ returns 0 if at least one element of the vector is 0.

Should NA values be omitted?

- +

Value

The geometric mean

-

Examples

-
geomean(c(1, 3, 9))
#> [1] 3
geomean(c(1, 3, NA, 9))
#> [1] 3
if (FALSE) geomean(c(1, -3, 9)) # returns an error
+
geomean(c(1, 3, 9))
#> [1] 3
geomean(c(1, 3, NA, 9))
#> [1] NA
if (FALSE) geomean(c(1, -3, 9)) # returns an error
-

Create a time series of decline data

-
one_box(x, ini, ..., t_end = 100, res = 0.01)
@@ -115,13 +115,11 @@
 one_box(x, ini = 1, ..., t_end = 100, res = 0.01)
 
 # S3 method for character
-one_box(x, ini = 1, parms, ..., t_end = 100,
-  res = 0.01)
+one_box(x, ini = 1, parms, ..., t_end = 100, res = 0.01)
 
 # S3 method for mkinfit
-one_box(x, ini = "model", ..., t_end = 100,
-  res = 0.01)
- +one_box(x, ini = "model", ..., t_end = 100, res = 0.01)
+

Arguments

@@ -158,11 +156,10 @@ all observed variables.

A named numeric vector containing the model parameters

- +

Value

An object of class one_box, inheriting from ts.

-

Examples

# Only use a half-life @@ -181,9 +178,7 @@ all observed variables.

Contents

diff --git a/docs/reference/pfm_degradation.html b/docs/reference/pfm_degradation.html index 7e4eab1..d2e62f6 100644 --- a/docs/reference/pfm_degradation.html +++ b/docs/reference/pfm_degradation.html @@ -8,11 +8,13 @@ Calculate a time course of relative concentrations based on an mkinmod model — pfm_degradation • pfm + + @@ -32,13 +34,14 @@ - + + @@ -82,7 +85,6 @@ Reference - @@ -104,15 +106,18 @@
-

Calculate a time course of relative concentrations based on an mkinmod model

-
-
pfm_degradation(model = "SFO", DT50 = 1000, parms = c(k_parent_sink =
-  log(2)/DT50), years = 1, step_days = 1, times = seq(0, years * 365,
-  by = step_days))
- +
pfm_degradation(
+  model = "SFO",
+  DT50 = 1000,
+  parms = c(k_parent_sink = log(2)/DT50),
+  years = 1,
+  step_days = 1,
+  times = seq(0, years * 365, by = step_days)
+)
+

Arguments

@@ -143,7 +148,7 @@ is calculated (SFO model).

The output times

- +

Examples

head(pfm_degradation("SFO", DT50 = 10))
#> time parent @@ -158,7 +163,6 @@ is calculated (SFO model).

Contents

diff --git a/docs/reference/plot.TOXSWA_cwa.html b/docs/reference/plot.TOXSWA_cwa.html index 8ca5b8e..1262c71 100644 --- a/docs/reference/plot.TOXSWA_cwa.html +++ b/docs/reference/plot.TOXSWA_cwa.html @@ -8,11 +8,13 @@ Plot TOXSWA surface water concentrations — plot.TOXSWA_cwa • pfm + + @@ -32,14 +34,15 @@ - + + @@ -83,7 +86,6 @@ segment of a TOXSWA surface water body." /> Reference - @@ -105,18 +107,24 @@ segment of a TOXSWA surface water body." />
-

Plot TOXSWA hourly concentrations of a chemical substance in a specific segment of a TOXSWA surface water body.

-
# S3 method for TOXSWA_cwa
-plot(x, time_column = c("datetime", "t",
-  "t_firstjan", "t_rel_to_max"), xlab = "default", ylab = "default",
-  add = FALSE, threshold_factor = 1000, thin_low = 1,
-  total = FALSE, LC_TIME = "C", ...)
- +plot( + x, + time_column = c("datetime", "t", "t_firstjan", "t_rel_to_max"), + xlab = "default", + ylab = "default", + add = FALSE, + threshold_factor = 1000, + thin_low = 1, + total = FALSE, + LC_TIME = "C", + ... +)
+

Arguments

@@ -162,7 +170,7 @@ to suspended matter?

Further arguments passed to plot if we are not adding to an existing plot

- +

Examples

H_sw_D4_pond <- read.TOXSWA_cwa("00001p_pa.cwa", @@ -178,7 +186,6 @@ to suspended matter?

Contents

diff --git a/docs/reference/plot.one_box-3.png b/docs/reference/plot.one_box-3.png index fc8116b..ad93165 100644 Binary files a/docs/reference/plot.one_box-3.png and b/docs/reference/plot.one_box-3.png differ diff --git a/docs/reference/plot.one_box.html b/docs/reference/plot.one_box.html index d048d22..75b8fe9 100644 --- a/docs/reference/plot.one_box.html +++ b/docs/reference/plot.one_box.html @@ -8,11 +8,13 @@ Plot time series of decline data — plot.one_box • pfm + + @@ -32,13 +34,14 @@ - + + @@ -82,7 +85,6 @@ Reference - @@ -104,16 +106,21 @@
-

Plot time series of decline data

-
# S3 method for one_box
-plot(x, xlim = range(time(x)), ylim = c(0, max(x)),
-  xlab = "Time", ylab = "Residue", max_twa = NULL,
-  max_twa_var = dimnames(x)[[2]][1], ...)
- +plot( + x, + xlim = range(time(x)), + ylim = c(0, max(x)), + xlab = "Time", + ylab = "Residue", + max_twa = NULL, + max_twa_var = dimnames(x)[[2]][1], + ... +)
+

Arguments

@@ -152,11 +159,10 @@ be shown if max_twa is not NULL.

Further arguments passed to methods

- +

See also

-

Examples

dfop_pred <- one_box("DFOP", parms = c(k1 = 0.2, k2 = 0.02, g = 0.7)) @@ -170,9 +176,7 @@ be shown if max_twa is not NULL.

Contents

diff --git a/docs/reference/read.TOXSWA_cwa.html b/docs/reference/read.TOXSWA_cwa.html index df84634..9c5c2a0 100644 --- a/docs/reference/read.TOXSWA_cwa.html +++ b/docs/reference/read.TOXSWA_cwa.html @@ -8,11 +8,13 @@ Read TOXSWA surface water concentrations — read.TOXSWA_cwa • pfm + + @@ -32,8 +34,8 @@ - + + @@ -87,7 +90,6 @@ renamed to ConLiqWatLay in the out file." /> Reference - @@ -109,20 +111,25 @@ renamed to ConLiqWatLay in the out file." />
-

Read TOXSWA hourly concentrations of a chemical substance in a specific segment of a TOXSWA surface water body. Per default, the data for the last segment are imported. As TOXSWA 4 reports the values at the end of the hour (ConLiqWatLayCur) in its summary file, we use this value as well instead of the hourly averages (ConLiqWatLay). In TOXSWA 5.5.3 this variable was renamed to ConLiqWatLay in the out file.

-
-
read.TOXSWA_cwa(filename, basedir = ".", zipfile = NULL,
-  segment = "last", substance = "parent", total = FALSE,
-  windows = NULL, thresholds = NULL)
- +
read.TOXSWA_cwa(
+  filename,
+  basedir = ".",
+  zipfile = NULL,
+  segment = "last",
+  substance = "parent",
+  total = FALSE,
+  windows = NULL,
+  thresholds = NULL
+)
+

Arguments

@@ -167,12 +174,11 @@ maximum time weighted average concentrations and areas under the curve.

generating event statistics.

- +

Value

An instance of an R6 object of class TOXSWA_cwa.

-

Examples

H_sw_D4_pond <- read.TOXSWA_cwa("00001p_pa.cwa", @@ -184,9 +190,7 @@ generating event statistics.

Contents

diff --git a/docs/reference/sawtooth-2.png b/docs/reference/sawtooth-2.png index fc8116b..ad93165 100644 Binary files a/docs/reference/sawtooth-2.png and b/docs/reference/sawtooth-2.png differ diff --git a/docs/reference/sawtooth.html b/docs/reference/sawtooth.html index c6756a9..7720afc 100644 --- a/docs/reference/sawtooth.html +++ b/docs/reference/sawtooth.html @@ -8,11 +8,13 @@ Create decline time series for multiple applications — sawtooth • pfm + + @@ -32,14 +34,15 @@ - + + @@ -83,7 +86,6 @@ n and i are disregarded." /> Reference - @@ -105,15 +107,17 @@ n and i are disregarded." />
-

If the application pattern is specified in applications, n and i are disregarded.

-
-
sawtooth(x, n = 1, i = 365, applications = data.frame(time = seq(0,
-  (n - 1) * i, length.out = n), amount = 1))
- +
sawtooth(
+  x,
+  n = 1,
+  i = 365,
+  applications = data.frame(time = seq(0, (n - 1) * i, length.out = n), amount = 1)
+)
+

Arguments

@@ -136,7 +140,7 @@ is ignored

the corresponding amounts applied in the second column.

- +

Examples

applications = data.frame(time = seq(0, 14, by = 7), amount = c(1, 2, 3)) @@ -162,7 +166,6 @@ the corresponding amounts applied in the second column.

Contents

diff --git a/docs/reference/set_nd_nq.html b/docs/reference/set_nd_nq.html index 9ec17ea..702b3e3 100644 --- a/docs/reference/set_nd_nq.html +++ b/docs/reference/set_nd_nq.html @@ -119,8 +119,14 @@ it automates the proposal of Boesten et al (2015).

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)
+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

diff --git a/man/FOCUS_Step_12_scenarios.Rd b/man/FOCUS_Step_12_scenarios.Rd index f58dea7..0547d61 100644 --- a/man/FOCUS_Step_12_scenarios.Rd +++ b/man/FOCUS_Step_12_scenarios.Rd @@ -19,14 +19,14 @@ The text file is not included in the package as its licence is not clear. scenario_path <- "inst/extdata/FOCUS_Step_12_scenarios.txt" scenarios <- readLines(scenario_path)[9:38] FOCUS_Step_12_scenarios <- list() - sce <- read.table(text = scenarios, sep = "\\t", header = TRUE, check.names = FALSE, + sce <- read.table(text = scenarios, sep = "\t", header = TRUE, check.names = FALSE, stringsAsFactors = FALSE) FOCUS_Step_12_scenarios$names = sce$Crop rownames(sce) <- sce$Crop FOCUS_Step_12_scenarios$drift = sce[, 3:11] FOCUS_Step_12_scenarios$interception = sce[, 12:15] sce_2 <- readLines(scenario_path)[41:46] - rd <- read.table(text = sce_2, sep = "\\t")[1:2] + rd <- read.table(text = sce_2, sep = "\t")[1:2] rd_mat <- matrix(rd$V2, nrow = 3, byrow = FALSE) dimnames(rd_mat) = list(Time = c("Oct-Feb", "Mar-May", "Jun-Sep"), Region = c("North", "South")) diff --git a/man/FOMC_actual_twa.Rd b/man/FOMC_actual_twa.Rd index 2c40048..a0c7284 100644 --- a/man/FOMC_actual_twa.Rd +++ b/man/FOMC_actual_twa.Rd @@ -9,8 +9,11 @@ FOCUS (2014) Generic Guidance for Estimating Persistence and Degradation 18 December 2014, p. 251 } \usage{ -FOMC_actual_twa(alpha = 1.0001, beta = 10, times = c(0, 1, 2, 4, 7, - 14, 21, 28, 42, 50, 100)) +FOMC_actual_twa( + alpha = 1.0001, + beta = 10, + times = c(0, 1, 2, 4, 7, 14, 21, 28, 42, 50, 100) +) } \arguments{ \item{alpha}{Parameter of the FOMC model} diff --git a/man/GUS.Rd b/man/GUS.Rd index adc1bb3..cd1a332 100644 --- a/man/GUS.Rd +++ b/man/GUS.Rd @@ -11,10 +11,16 @@ GUS(...) \method{GUS}{numeric}(DT50, Koc, ...) -\method{GUS}{chent}(chent, degradation_value = "DT50ref", - lab_field = "laboratory", redox = "aerobic", - sorption_value = "Kfoc", degradation_aggregator = geomean, - sorption_aggregator = geomean, ...) +\method{GUS}{chent}( + chent, + degradation_value = "DT50ref", + lab_field = "laboratory", + redox = "aerobic", + sorption_value = "Kfoc", + degradation_aggregator = geomean, + sorption_aggregator = geomean, + ... +) \method{print}{GUS_result}(x, ..., digits = 1) } diff --git a/man/PEC_soil.Rd b/man/PEC_soil.Rd index a9e6c49..a198f24 100644 --- a/man/PEC_soil.Rd +++ b/man/PEC_soil.Rd @@ -4,14 +4,30 @@ \alias{PEC_soil} \title{Calculate predicted environmental concentrations in soil} \usage{ -PEC_soil(rate, rate_units = "g/ha", interception = 0, - mixing_depth = 5, PEC_units = "mg/kg", PEC_pw_units = "mg/L", - interval = NA, n_periods = Inf, tillage_depth = 20, - leaching_depth = tillage_depth, crop = "annual", - cultivation = FALSE, chent = NA, DT50 = NA, FOMC = NA, - Koc = NA, Kom = Koc/1.724, t_avg = 0, t_act = NULL, +PEC_soil( + rate, + rate_units = "g/ha", + interception = 0, + mixing_depth = 5, + PEC_units = "mg/kg", + PEC_pw_units = "mg/L", + interval = NA, + n_periods = Inf, + tillage_depth = 20, + leaching_depth = tillage_depth, + crop = "annual", + cultivation = FALSE, + chent = NA, + DT50 = NA, + FOMC = NA, + Koc = NA, + Kom = Koc/1.724, + t_avg = 0, + t_act = NULL, scenarios = c("default", "EFSA_2017", "EFSA_2015"), - leaching = scenarios == "EFSA_2017", porewater = FALSE) + leaching = scenarios == "EFSA_2017", + porewater = FALSE +) } \arguments{ \item{rate}{Application rate in units specified below} diff --git a/man/PEC_sw_drainage_UK.Rd b/man/PEC_sw_drainage_UK.Rd index c9f8ed4..98aa868 100644 --- a/man/PEC_sw_drainage_UK.Rd +++ b/man/PEC_sw_drainage_UK.Rd @@ -4,9 +4,15 @@ \alias{PEC_sw_drainage_UK} \title{Calculate initial predicted environmental concentrations in surface water due to drainage using the UK method} \usage{ -PEC_sw_drainage_UK(rate, interception = 0, Koc, - latest_application = NULL, soil_DT50 = NULL, model = NULL, - model_parms = NULL) +PEC_sw_drainage_UK( + rate, + interception = 0, + Koc, + latest_application = NULL, + soil_DT50 = NULL, + model = NULL, + model_parms = NULL +) } \arguments{ \item{rate}{Application rate in g/ha} diff --git a/man/PEC_sw_drift.Rd b/man/PEC_sw_drift.Rd index dfc3f39..cde3c78 100644 --- a/man/PEC_sw_drift.Rd +++ b/man/PEC_sw_drift.Rd @@ -4,10 +4,17 @@ \alias{PEC_sw_drift} \title{Calculate predicted environmental concentrations in surface water due to drift} \usage{ -PEC_sw_drift(rate, applications = 1, water_depth = 30, - drift_percentages = NULL, drift_data = "JKI", crop = "Ackerbau", - distances = c(1, 5, 10, 20), rate_units = "g/ha", - PEC_units = "µg/L") +PEC_sw_drift( + rate, + applications = 1, + water_depth = 30, + drift_percentages = NULL, + drift_data = "JKI", + crop = "Ackerbau", + distances = c(1, 5, 10, 20), + rate_units = "g/ha", + PEC_units = "µg/L" +) } \arguments{ \item{rate}{Application rate in units specified below} diff --git a/man/PEC_sw_exposit_drainage.Rd b/man/PEC_sw_exposit_drainage.Rd index 237d8cf..5a543c8 100644 --- a/man/PEC_sw_exposit_drainage.Rd +++ b/man/PEC_sw_exposit_drainage.Rd @@ -8,10 +8,17 @@ Excel 3.02 spreadsheet available from \url{https://www.bvl.bund.de/DE/04_Pflanzenschutzmittel/03_Antragsteller/04_Zulassungsverfahren/07_Naturhaushalt/psm_naturhaush_node.html#doc1400590bodyText3} } \usage{ -PEC_sw_exposit_drainage(rate, interception = 0, Koc = NA, - mobility = c(NA, "low", "high"), DT50 = Inf, t_drainage = 3, - V_ditch = 30, V_drainage = c(spring = 10, autumn = 100), - dilution = 2) +PEC_sw_exposit_drainage( + rate, + interception = 0, + Koc = NA, + mobility = c(NA, "low", "high"), + DT50 = Inf, + t_drainage = 3, + V_ditch = 30, + V_drainage = c(spring = 10, autumn = 100), + dilution = 2 +) } \arguments{ \item{rate}{The application rate in g/ha} diff --git a/man/PEC_sw_exposit_runoff.Rd b/man/PEC_sw_exposit_runoff.Rd index c73270b..a415a63 100644 --- a/man/PEC_sw_exposit_runoff.Rd +++ b/man/PEC_sw_exposit_runoff.Rd @@ -8,9 +8,17 @@ Excel 3.02 spreadsheet available from \url{https://www.bvl.bund.de/DE/04_Pflanzenschutzmittel/03_Antragsteller/04_Zulassungsverfahren/07_Naturhaushalt/psm_naturhaush_node.html#doc1400590bodyText3} } \usage{ -PEC_sw_exposit_runoff(rate, interception = 0, Koc, DT50 = Inf, - t_runoff = 3, exposit_reduction_version = c("3.02", "3.01a", - "3.01a2", "2.0"), V_ditch = 30, V_event = 100, dilution = 2) +PEC_sw_exposit_runoff( + rate, + interception = 0, + Koc, + DT50 = Inf, + t_runoff = 3, + exposit_reduction_version = c("3.02", "3.01a", "3.01a2", "2.0"), + V_ditch = 30, + V_event = 100, + dilution = 2 +) } \arguments{ \item{rate}{The application rate in g/ha} diff --git a/man/PEC_sw_focus.Rd b/man/PEC_sw_focus.Rd index 836ed86..3ad1ad0 100644 --- a/man/PEC_sw_focus.Rd +++ b/man/PEC_sw_focus.Rd @@ -4,12 +4,25 @@ \alias{PEC_sw_focus} \title{Calculate PEC surface water at FOCUS Step 1} \usage{ -PEC_sw_focus(parent, rate, n = 1, i = NA, comment = "", met = NULL, - f_drift = NA, f_rd = 0.1, scenario = FOCUS_Step_12_scenarios$names, - region = c("n", "s"), season = c(NA, "of", "mm", "js"), - interception = c("no interception", "minimal crop cover", - "average crop cover", "full canopy"), met_form_water = TRUE, - txt_file = "pesticide.txt", overwrite = FALSE, append = TRUE) +PEC_sw_focus( + parent, + rate, + n = 1, + i = NA, + comment = "", + met = NULL, + f_drift = NA, + f_rd = 0.1, + scenario = FOCUS_Step_12_scenarios$names, + region = c("n", "s"), + season = c(NA, "of", "mm", "js"), + interception = c("no interception", "minimal crop cover", "average crop cover", + "full canopy"), + met_form_water = TRUE, + txt_file = "pesticide.txt", + overwrite = FALSE, + append = TRUE +) } \arguments{ \item{parent}{A list containing substance specific parameters, e.g. diff --git a/man/PEC_sw_sed.Rd b/man/PEC_sw_sed.Rd index 1feb146..bc82ee3 100644 --- a/man/PEC_sw_sed.Rd +++ b/man/PEC_sw_sed.Rd @@ -5,9 +5,15 @@ \title{Calculate predicted environmental concentrations in sediment from surface water concentrations} \usage{ -PEC_sw_sed(PEC_sw, percentage = 100, method = "percentage", - sediment_depth = 5, water_depth = 30, sediment_density = 1.3, - PEC_sed_units = c("µg/kg", "mg/kg")) +PEC_sw_sed( + PEC_sw, + percentage = 100, + method = "percentage", + sediment_depth = 5, + water_depth = 30, + sediment_density = 1.3, + PEC_sed_units = c("µg/kg", "mg/kg") +) } \arguments{ \item{PEC_sw}{Numeric vector or matrix of surface water concentrations in µg/L for diff --git a/man/SFO_actual_twa.Rd b/man/SFO_actual_twa.Rd index 30039f2..bdf4c4d 100644 --- a/man/SFO_actual_twa.Rd +++ b/man/SFO_actual_twa.Rd @@ -9,8 +9,7 @@ FOCUS (2014) Generic Guidance for Estimating Persistence and Degradation 18 December 2014, p. 251 } \usage{ -SFO_actual_twa(DT50 = 1000, times = c(0, 1, 2, 4, 7, 14, 21, 28, 42, - 50, 100)) +SFO_actual_twa(DT50 = 1000, times = c(0, 1, 2, 4, 7, 14, 21, 28, 42, 50, 100)) } \arguments{ \item{DT50}{The half-life.} diff --git a/man/TOXSWA_cwa.Rd b/man/TOXSWA_cwa.Rd index f073180..eb3fe38 100644 --- a/man/TOXSWA_cwa.Rd +++ b/man/TOXSWA_cwa.Rd @@ -5,31 +5,10 @@ \alias{TOXSWA_cwa} \title{R6 class for holding TOXSWA water concentration data and associated statistics} \format{An \code{\link{R6Class}} generator object.} -\usage{ -TOXSWA_cwa -} \description{ An R6 class for holding TOXSWA water concentration (cwa) data and some associated statistics. Usually, an instance of this class will be generated by \code{\link{read.TOXSWA_cwa}}. } -\section{Fields}{ - -\describe{ -\item{\code{filename}}{Length one character vector.} - -\item{\code{basedir}}{Length one character vector.} - -\item{\code{segment}}{Length one integer, specifying for which segment the cwa data were read.} - -\item{\code{cwas}}{Dataframe holding the concentrations.} - -\item{\code{events}}{List of dataframes holding the event statistics for each threshold.} - -\item{\code{windows}}{Matrix of maximum time weighted average concentrations (TWAC_max) -and areas under the curve in µg/day * h (AUC_max_h) or µg/day * d (AUC_max_d) -for the requested moving window sizes in days.} -}} - \section{Methods}{ \describe{ @@ -57,3 +36,88 @@ H_sw_R1_stream$moving_windows(c(7, 21)) print(H_sw_R1_stream) } \keyword{data} +\section{Public fields}{ +\if{html}{\out{
}} +\describe{ +\item{\code{filename}}{Length one character vector.} + +\item{\code{basedir}}{Length one character vector.} + +\item{\code{segment}}{Length one integer, specifying for which segment the cwa data were read.} + +\item{\code{cwas}}{Dataframe holding the concentrations.} + +\item{\code{events}}{List of dataframes holding the event statistics for each threshold.} + +\item{\code{windows}}{Matrix of maximum time weighted average concentrations (TWAC_max) +and areas under the curve in µg/day * h (AUC_max_h) or µg/day * d (AUC_max_d) +for the requested moving window sizes in days.} +} +\if{html}{\out{
}} +} +\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()}} +} +} +\if{html}{\out{
}} +\if{html}{\out{}} +\subsection{Method \code{new()}}{ +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{TOXSWA_cwa$new( + filename, + basedir, + zipfile = NULL, + segment = "last", + substance = "parent", + total = FALSE +)}\if{html}{\out{
}} +} + +} +\if{html}{\out{
}} +\if{html}{\out{}} +\subsection{Method \code{moving_windows()}}{ +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{TOXSWA_cwa$moving_windows(windows, total = FALSE)}\if{html}{\out{
}} +} + +} +\if{html}{\out{
}} +\if{html}{\out{}} +\subsection{Method \code{get_events()}}{ +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{TOXSWA_cwa$get_events(thresholds, total = FALSE)}\if{html}{\out{
}} +} + +} +\if{html}{\out{
}} +\if{html}{\out{}} +\subsection{Method \code{print()}}{ +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{TOXSWA_cwa$print()}\if{html}{\out{
}} +} + +} +\if{html}{\out{
}} +\if{html}{\out{}} +\subsection{Method \code{clone()}}{ +The objects of this class are cloneable with this method. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{TOXSWA_cwa$clone(deep = FALSE)}\if{html}{\out{
}} +} + +\subsection{Arguments}{ +\if{html}{\out{
}} +\describe{ +\item{\code{deep}}{Whether to make a deep clone.} +} +\if{html}{\out{
}} +} +} +} diff --git a/man/chent_focus_sw.Rd b/man/chent_focus_sw.Rd index 9830ade..5f595d8 100644 --- a/man/chent_focus_sw.Rd +++ b/man/chent_focus_sw.Rd @@ -4,9 +4,18 @@ \alias{chent_focus_sw} \title{Create a chemical compound object for FOCUS Step 1 calculations} \usage{ -chent_focus_sw(name, Koc, DT50_ws = NA, DT50_soil = NA, - DT50_water = NA, DT50_sediment = NA, cwsat = 1000, mw = NA, - max_soil = 1, max_ws = 1) +chent_focus_sw( + name, + Koc, + DT50_ws = NA, + DT50_soil = NA, + DT50_water = NA, + DT50_sediment = NA, + cwsat = 1000, + mw = NA, + max_soil = 1, + max_ws = 1 +) } \arguments{ \item{name}{Length one character vector containing the name} diff --git a/man/endpoint.Rd b/man/endpoint.Rd index 204905b..2b66c21 100644 --- a/man/endpoint.Rd +++ b/man/endpoint.Rd @@ -8,23 +8,39 @@ \alias{soil_sorption} \title{Retrieve endpoint information from the chyaml field of a chent object} \usage{ -endpoint(chent, medium = "soil", type = c("degradation", "sorption"), - lab_field = c(NA, "laboratory", "field"), redox = c(NA, "aerobic", - "anaerobic"), value = c("DT50ref", "Kfoc", "N"), - aggregator = geomean, raw = FALSE, signif = 3) +endpoint( + chent, + medium = "soil", + type = c("degradation", "sorption"), + lab_field = c(NA, "laboratory", "field"), + redox = c(NA, "aerobic", "anaerobic"), + value = c("DT50ref", "Kfoc", "N"), + aggregator = geomean, + raw = FALSE, + signif = 3 +) -soil_DT50(chent, aggregator = geomean, signif = 3, - lab_field = "laboratory", value = "DT50ref", redox = "aerobic", - raw = FALSE) +soil_DT50( + chent, + aggregator = geomean, + signif = 3, + lab_field = "laboratory", + value = "DT50ref", + redox = "aerobic", + raw = FALSE +) -soil_Kfoc(chent, aggregator = geomean, signif = 3, value = "Kfoc", - raw = FALSE) +soil_Kfoc(chent, aggregator = geomean, signif = 3, value = "Kfoc", raw = FALSE) soil_N(chent, aggregator = mean, signif = 3, raw = FALSE) -soil_sorption(chent, values = c("Kfoc", "N"), aggregators = c(Kfoc = - geomean, Koc = geomean, N = mean), signif = c(Kfoc = 3, N = 3), - raw = FALSE) +soil_sorption( + chent, + values = c("Kfoc", "N"), + aggregators = c(Kfoc = geomean, Koc = geomean, N = mean), + signif = c(Kfoc = 3, N = 3), + raw = FALSE +) } \arguments{ \item{chent}{The chent object to get the information from} diff --git a/man/geomean.Rd b/man/geomean.Rd index 2887929..506e64d 100644 --- a/man/geomean.Rd +++ b/man/geomean.Rd @@ -4,7 +4,7 @@ \alias{geomean} \title{Calculate the geometric mean} \usage{ -geomean(x, na.rm = TRUE) +geomean(x, na.rm = FALSE) } \arguments{ \item{x}{Vector of numbers} @@ -17,8 +17,9 @@ The geometric mean \description{ Based on some posts in a thread on Stackoverflow \url{http://stackoverflow.com/questions/2602583/geometric-mean-is-there-a-built-in} -This function checks for negative values, removes NA values per default and -returns 0 if at least one element of the vector is 0. +This function returns NA if NA values are present and na.rm = FALSE +(default). If negative values are present, it gives an error message. +If at least one element of the vector is 0, it returns 0. } \examples{ geomean(c(1, 3, 9)) diff --git a/man/one_box.Rd b/man/one_box.Rd index 3c34dae..a60aa39 100644 --- a/man/one_box.Rd +++ b/man/one_box.Rd @@ -11,11 +11,9 @@ one_box(x, ini, ..., t_end = 100, res = 0.01) \method{one_box}{numeric}(x, ini = 1, ..., t_end = 100, res = 0.01) -\method{one_box}{character}(x, ini = 1, parms, ..., t_end = 100, - res = 0.01) +\method{one_box}{character}(x, ini = 1, parms, ..., t_end = 100, res = 0.01) -\method{one_box}{mkinfit}(x, ini = "model", ..., t_end = 100, - res = 0.01) +\method{one_box}{mkinfit}(x, ini = "model", ..., t_end = 100, res = 0.01) } \arguments{ \item{x}{When numeric, this is the half-life to be used for an exponential diff --git a/man/pfm_degradation.Rd b/man/pfm_degradation.Rd index fdc99fe..6684fa4 100644 --- a/man/pfm_degradation.Rd +++ b/man/pfm_degradation.Rd @@ -4,9 +4,14 @@ \alias{pfm_degradation} \title{Calculate a time course of relative concentrations based on an mkinmod model} \usage{ -pfm_degradation(model = "SFO", DT50 = 1000, parms = c(k_parent_sink = - log(2)/DT50), years = 1, step_days = 1, times = seq(0, years * 365, - by = step_days)) +pfm_degradation( + model = "SFO", + DT50 = 1000, + parms = c(k_parent_sink = log(2)/DT50), + years = 1, + step_days = 1, + times = seq(0, years * 365, by = step_days) +) } \arguments{ \item{model}{The degradation model to be used. Either a parent only model like diff --git a/man/plot.TOXSWA_cwa.Rd b/man/plot.TOXSWA_cwa.Rd index f06d3c7..7eeb3fc 100644 --- a/man/plot.TOXSWA_cwa.Rd +++ b/man/plot.TOXSWA_cwa.Rd @@ -4,10 +4,18 @@ \alias{plot.TOXSWA_cwa} \title{Plot TOXSWA surface water concentrations} \usage{ -\method{plot}{TOXSWA_cwa}(x, time_column = c("datetime", "t", - "t_firstjan", "t_rel_to_max"), xlab = "default", ylab = "default", - add = FALSE, threshold_factor = 1000, thin_low = 1, - total = FALSE, LC_TIME = "C", ...) +\method{plot}{TOXSWA_cwa}( + x, + time_column = c("datetime", "t", "t_firstjan", "t_rel_to_max"), + xlab = "default", + ylab = "default", + add = FALSE, + threshold_factor = 1000, + thin_low = 1, + total = FALSE, + LC_TIME = "C", + ... +) } \arguments{ \item{x}{The TOXSWA_cwa object to be plotted.} diff --git a/man/plot.one_box.Rd b/man/plot.one_box.Rd index a212c11..35e7bf7 100644 --- a/man/plot.one_box.Rd +++ b/man/plot.one_box.Rd @@ -4,9 +4,16 @@ \alias{plot.one_box} \title{Plot time series of decline data} \usage{ -\method{plot}{one_box}(x, xlim = range(time(x)), ylim = c(0, max(x)), - xlab = "Time", ylab = "Residue", max_twa = NULL, - max_twa_var = dimnames(x)[[2]][1], ...) +\method{plot}{one_box}( + x, + xlim = range(time(x)), + ylim = c(0, max(x)), + xlab = "Time", + ylab = "Residue", + max_twa = NULL, + max_twa_var = dimnames(x)[[2]][1], + ... +) } \arguments{ \item{x}{The object of type \code{\link{one_box}} to be plotted} diff --git a/man/read.TOXSWA_cwa.Rd b/man/read.TOXSWA_cwa.Rd index ccd403a..b6ee4f6 100644 --- a/man/read.TOXSWA_cwa.Rd +++ b/man/read.TOXSWA_cwa.Rd @@ -4,9 +4,16 @@ \alias{read.TOXSWA_cwa} \title{Read TOXSWA surface water concentrations} \usage{ -read.TOXSWA_cwa(filename, basedir = ".", zipfile = NULL, - segment = "last", substance = "parent", total = FALSE, - windows = NULL, thresholds = NULL) +read.TOXSWA_cwa( + filename, + basedir = ".", + zipfile = NULL, + segment = "last", + substance = "parent", + total = FALSE, + windows = NULL, + thresholds = NULL +) } \arguments{ \item{filename}{The filename of the cwa file (TOXSWA 2.x.y or similar) or the diff --git a/man/sawtooth.Rd b/man/sawtooth.Rd index 007f00d..44ab2be 100644 --- a/man/sawtooth.Rd +++ b/man/sawtooth.Rd @@ -4,8 +4,12 @@ \alias{sawtooth} \title{Create decline time series for multiple applications} \usage{ -sawtooth(x, n = 1, i = 365, applications = data.frame(time = seq(0, - (n - 1) * i, length.out = n), amount = 1)) +sawtooth( + x, + n = 1, + i = 365, + applications = data.frame(time = seq(0, (n - 1) * i, length.out = n), amount = 1) +) } \arguments{ \item{x}{A \code{\link{one_box}} object} diff --git a/man/set_nd_nq.Rd b/man/set_nd_nq.Rd index 47b7e33..7135d0d 100644 --- a/man/set_nd_nq.Rd +++ b/man/set_nd_nq.Rd @@ -7,8 +7,14 @@ \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) +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 diff --git a/tests/testthat/test_geomean.R b/tests/testthat/test_geomean.R index 0cc3416..bf298c2 100644 --- a/tests/testthat/test_geomean.R +++ b/tests/testthat/test_geomean.R @@ -4,8 +4,8 @@ context("Geometric mean calculation") test_that("The geometric mean is correctly calculated", { expect_equal(geomean(c(1, 3, 9)), 3) expect_equal(geomean(c(0, 3, 9)), 0) - expect_error(geomean(c(1, 3, NA, 9), na.rm = FALSE), "NA") + expect_equal(geomean(c(1, 3, NA, 9), na.rm = FALSE), NA) expect_equal(geomean(c(1, 3, NA, 9), na.rm = TRUE), 3) expect_error(geomean(c(1, -3, 9)), "positive") - expect_error(geomean(c(1, -3, NA, 9)), "positive") + expect_equal(geomean(c(1, -3, NA, 9)), NA) }) -- cgit v1.2.1