From a6d61c06d573574cf574ed893cc13808a9e8b785 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 19 Jan 2017 09:20:22 +0100 Subject: Fix order of arguments to one_box, correct docs --- ChangeLog | 56 ++++++++++++++++++++++++++++++++++++++ DESCRIPTION | 2 +- R/twa.R | 15 +++++----- docs/reference/one_box.html | 12 ++++---- docs/reference/plot.one_box-8.png | Bin 0 -> 13603 bytes docs/reference/plot.one_box.html | 4 ++- man/one_box.Rd | 12 ++++---- man/plot.one_box.Rd | 1 + 8 files changed, 81 insertions(+), 21 deletions(-) create mode 100644 docs/reference/plot.one_box-8.png diff --git a/ChangeLog b/ChangeLog index fd5074e..318f3c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,59 @@ +commit b8ac1393b9e1bef8c48b26b790cf5759ccd69fed +Author: Johannes Ranke +Date: 2017-01-19 09:10:37 +0100 + + Predict parent decline without fitting for non-SFO models + +commit 3d4f6f8c582c19c38587ead305a1229ff069da63 +Author: Johannes Ranke +Date: 2017-01-19 08:24:44 +0100 + + Switch sawtooth plotting example to FOMC + + as this it is claimed in the README that an mkinfit prediction is used. + - Add another seealso link + - Delete trailing whitespace + +commit 9b5faa8b8475bdd7624c58b07d45d28d42a47a2e +Author: Johannes Ranke +Date: 2017-01-18 23:02:14 +0100 + + Point to the github.io documentation site + +commit cff68edc1ac113ac9e159dfdf7cfcbb6721ff2a7 +Author: Johannes Ranke +Date: 2017-01-18 22:58:51 +0100 + + Make README.md simple, and point to the reference + +commit a76221d87485029444c8e684022ca606a0c7e68d +Author: Johannes Ranke +Date: 2017-01-18 22:41:01 +0100 + + Update static docs using pkgdown + + - Add _pkgdown.yml for a structured function/data reference + - Make seealso links active + - Make mkinfit calls quiet + - Use pkgdown branch from pull request hadley/pkgdown#229 to have topics + ordered + +commit a1d9f93138c2cfed92a683e37e72c737d52b7ad7 +Author: Johannes Ranke +Date: 2017-01-18 19:58:13 +0100 + + One box time series and twa values + + - one_box() creates decline time series from mkinfit objects or simply + from a half-life + - sawtooth() generates sawtooth curves for arbitrary application + patterns and decline models + - twa() calculates moving window averages + - max_twa() gives their maxima and + - plot.one_box() can plot series generated by one_box() or sawtooth(), + optionally adding a greay rectangle to illustrate the maximum moving + window time weighted average + commit bba2cf3a70849ba86f37520d3e909cf1c706f416 Author: Johannes Ranke Date: 2016-12-22 11:06:57 +0100 diff --git a/DESCRIPTION b/DESCRIPTION index f92e6da..b15262c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: pfm Type: Package Title: Utilities for Pesticide Fate Modelling Version: 0.4-1 -Date: 2017-01-18 +Date: 2017-01-19 Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de", role = c("aut", "cre", "cph")) Description: Utilities for simple calculations of predicted environmental diff --git a/R/twa.R b/R/twa.R index e3c0076..c936805 100644 --- a/R/twa.R +++ b/R/twa.R @@ -44,16 +44,16 @@ #' fit_2 <- mkinfit(m_2, FOCUS_2006_D, quiet = TRUE) #' pred_2 <- one_box(fit_2) #' plot(pred_2) -one_box <- function(x, - t_end = 100, res = 0.01, ...) +one_box <- function(x, ..., + t_end = 100, res = 0.01) { UseMethod("one_box") } #' @rdname one_box #' @export -one_box.numeric <- function(x, - t_end = 100, res = 0.01, ...) +one_box.numeric <- function(x, ..., + t_end = 100, res = 0.01) { half_life = x k = log(2)/half_life @@ -68,8 +68,8 @@ one_box.numeric <- function(x, #' @rdname one_box #' @param parms A named numeric vector containing the model parameters #' @export -one_box.character <- function(x, parms, - t_end = 100, res = 0.01, ...) +one_box.character <- function(x, parms, ..., + t_end = 100, res = 0.01) { parent_models_available = c("SFO", "FOMC", "DFOP", "HS", "SFORB", "IORE") if (length(x) == 1 & x %in% parent_models_available) { @@ -96,7 +96,7 @@ one_box.character <- function(x, parms, #' @rdname one_box #' @importFrom mkin mkinpredict #' @export -one_box.mkinfit <- function(x, t_end = 100, res = 0.01, ...) { +one_box.mkinfit <- function(x, ..., t_end = 100, res = 0.01) { fit <- x t_out = seq(0, t_end, by = res) odeini <- c(1, rep(0, length(fit$mkinmod$spec) - 1)) @@ -134,6 +134,7 @@ one_box.mkinfit <- function(x, t_end = 100, res = 0.01, ...) { #' # Use a fitted mkinfit model #' m_2 <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO")) #' fit_2 <- mkinfit(m_2, FOCUS_2006_D, quiet = TRUE) +#' pred_2 <- one_box(fit_2) #' pred_2_saw <- sawtooth(pred_2, 2, 7) #' plot(pred_2_saw, max_twa = 21, max_twa_var = "m1") plot.one_box <- function(x, diff --git a/docs/reference/one_box.html b/docs/reference/one_box.html index c8f8ad3..698f887 100644 --- a/docs/reference/one_box.html +++ b/docs/reference/one_box.html @@ -74,28 +74,28 @@ This does not create objects of type ts.

-
one_box(x, t_end = 100, res = 0.01, ...)
+    
one_box(x, ..., t_end = 100, res = 0.01)
 
 # S3 method for numeric
-one_box(x, t_end = 100, res = 0.01, ...)
+one_box(x, ..., t_end = 100, res = 0.01)
 
 # S3 method for character
-one_box(x, parms, t_end = 100, res = 0.01, ...)
+one_box(x, parms, ..., t_end = 100, res = 0.01)
 
 # S3 method for mkinfit
-one_box(x, t_end = 100, res = 0.01, ...)
+one_box(x, ..., t_end = 100, res = 0.01)

Arguments

x
When numeric, this is the half-life to be used for an exponential decline. If x is an mkinfit object, the decline is calculated from this object
+
...
+
Further arguments passed to methods
t_end
End of the time series
res
Resolution of the time series
-
...
-
Further arguments passed to methods
parms
A named numeric vector containing the model parameters
diff --git a/docs/reference/plot.one_box-8.png b/docs/reference/plot.one_box-8.png new file mode 100644 index 0000000..161ecb4 Binary files /dev/null and b/docs/reference/plot.one_box-8.png differ diff --git a/docs/reference/plot.one_box.html b/docs/reference/plot.one_box.html index ec784c5..d43c415 100644 --- a/docs/reference/plot.one_box.html +++ b/docs/reference/plot.one_box.html @@ -110,7 +110,9 @@ be shown if max_twa is not NULL. plot(dfop_pred)
plot(sawtooth(dfop_pred, 3, 7), max_twa = 21)
# Use a fitted mkinfit model m_2 <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
fit_2 <- mkinfit(m_2, FOCUS_2006_D, quiet = TRUE) -pred_2_saw <- sawtooth(pred_2, 2, 7)
#> Error in as.matrix(x): Objekt 'pred_2' nicht gefunden
plot(pred_2_saw, max_twa = 21, max_twa_var = "m1")
#> Error in plot(pred_2_saw, max_twa = 21, max_twa_var = "m1"): Objekt 'pred_2_saw' nicht gefunden
+pred_2 <- one_box(fit_2) +pred_2_saw <- sawtooth(pred_2, 2, 7) +plot(pred_2_saw, max_twa = 21, max_twa_var = "m1")