aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2017-01-19 09:20:22 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2017-01-19 09:20:22 +0100
commita6d61c06d573574cf574ed893cc13808a9e8b785 (patch)
tree6ff3587e1445ed57861f22cb7074257238366a0f
parentb8ac1393b9e1bef8c48b26b790cf5759ccd69fed (diff)
Fix order of arguments to one_box, correct docs
-rw-r--r--ChangeLog56
-rw-r--r--DESCRIPTION2
-rw-r--r--R/twa.R15
-rw-r--r--docs/reference/one_box.html12
-rw-r--r--docs/reference/plot.one_box-8.pngbin0 -> 13603 bytes
-rw-r--r--docs/reference/plot.one_box.html4
-rw-r--r--man/one_box.Rd12
-rw-r--r--man/plot.one_box.Rd1
8 files changed, 81 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index fd5074e..318f3c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,59 @@
+commit b8ac1393b9e1bef8c48b26b790cf5759ccd69fed
+Author: Johannes Ranke <jranke@uni-bremen.de>
+Date: 2017-01-19 09:10:37 +0100
+
+ Predict parent decline without fitting for non-SFO models
+
+commit 3d4f6f8c582c19c38587ead305a1229ff069da63
+Author: Johannes Ranke <jranke@uni-bremen.de>
+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 <jranke@uni-bremen.de>
+Date: 2017-01-18 23:02:14 +0100
+
+ Point to the github.io documentation site
+
+commit cff68edc1ac113ac9e159dfdf7cfcbb6721ff2a7
+Author: Johannes Ranke <jranke@uni-bremen.de>
+Date: 2017-01-18 22:58:51 +0100
+
+ Make README.md simple, and point to the reference
+
+commit a76221d87485029444c8e684022ca606a0c7e68d
+Author: Johannes Ranke <jranke@uni-bremen.de>
+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 <jranke@uni-bremen.de>
+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 <jranke@uni-bremen.de>
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 <code>ts</code>.</p>
- <pre><span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>, <span class='no'>...</span>)
+ <pre><span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='no'>...</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>)
<span class='co'># S3 method for numeric</span>
-<span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>, <span class='no'>...</span>)
+<span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='no'>...</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>)
<span class='co'># S3 method for character</span>
-<span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='no'>parms</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>, <span class='no'>...</span>)
+<span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='no'>parms</span>, <span class='no'>...</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>)
<span class='co'># S3 method for mkinfit</span>
-<span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>, <span class='no'>...</span>)</pre>
+<span class='fu'>one_box</span>(<span class='no'>x</span>, <span class='no'>...</span>, <span class='kw'>t_end</span> <span class='kw'>=</span> <span class='fl'>100</span>, <span class='kw'>res</span> <span class='kw'>=</span> <span class='fl'>0.01</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a> Arguments</h2>
<dl class="dl-horizontal">
<dt>x</dt>
<dd>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</dd>
+ <dt>...</dt>
+ <dd>Further arguments passed to methods</dd>
<dt>t_end</dt>
<dd>End of the time series</dd>
<dt>res</dt>
<dd>Resolution of the time series</dd>
- <dt>...</dt>
- <dd>Further arguments passed to methods</dd>
<dt>parms</dt>
<dd>A named numeric vector containing the model parameters</dd>
</dl>
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
--- /dev/null
+++ b/docs/reference/plot.one_box-8.png
Binary files 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.</dd>
<span class='fu'>plot</span>(<span class='no'>dfop_pred</span>)</div><img src='plot.one_box-2.png' alt='' width='540' height='400' /><div class='input'><span class='fu'>plot</span>(<span class='fu'><a href='sawtooth.html'>sawtooth</a></span>(<span class='no'>dfop_pred</span>, <span class='fl'>3</span>, <span class='fl'>7</span>), <span class='kw'>max_twa</span> <span class='kw'>=</span> <span class='fl'>21</span>)</div><img src='plot.one_box-4.png' alt='' width='540' height='400' /><div class='input'>
<span class='co'># Use a fitted mkinfit model</span>
<span class='no'>m_2</span> <span class='kw'>&lt;-</span> <span class='fu'>mkinmod</span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'>mkinsub</span>(<span class='st'>"SFO"</span>, <span class='st'>"m1"</span>), <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'>mkinsub</span>(<span class='st'>"SFO"</span>))</div><div class='output co'>#&gt; <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'><span class='no'>fit_2</span> <span class='kw'>&lt;-</span> <span class='fu'>mkinfit</span>(<span class='no'>m_2</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
-<span class='no'>pred_2_saw</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='sawtooth.html'>sawtooth</a></span>(<span class='no'>pred_2</span>, <span class='fl'>2</span>, <span class='fl'>7</span>)</div><div class='output co'>#&gt; <span class='error'>Error in as.matrix(x): Objekt &#39;pred_2&#39; nicht gefunden</span></div><div class='input'><span class='fu'>plot</span>(<span class='no'>pred_2_saw</span>, <span class='kw'>max_twa</span> <span class='kw'>=</span> <span class='fl'>21</span>, <span class='kw'>max_twa_var</span> <span class='kw'>=</span> <span class='st'>"m1"</span>)</div><div class='output co'>#&gt; <span class='error'>Error in plot(pred_2_saw, max_twa = 21, max_twa_var = &quot;m1&quot;): Objekt &#39;pred_2_saw&#39; nicht gefunden</span></div></pre>
+<span class='no'>pred_2</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='one_box.html'>one_box</a></span>(<span class='no'>fit_2</span>)
+<span class='no'>pred_2_saw</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='sawtooth.html'>sawtooth</a></span>(<span class='no'>pred_2</span>, <span class='fl'>2</span>, <span class='fl'>7</span>)
+<span class='fu'>plot</span>(<span class='no'>pred_2_saw</span>, <span class='kw'>max_twa</span> <span class='kw'>=</span> <span class='fl'>21</span>, <span class='kw'>max_twa_var</span> <span class='kw'>=</span> <span class='st'>"m1"</span>)</div><img src='plot.one_box-8.png' alt='' width='540' height='400' /></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
diff --git a/man/one_box.Rd b/man/one_box.Rd
index dc524a8..5a46142 100644
--- a/man/one_box.Rd
+++ b/man/one_box.Rd
@@ -7,24 +7,24 @@
\alias{one_box.mkinfit}
\title{Create a time series of decline data}
\usage{
-one_box(x, t_end = 100, res = 0.01, ...)
+one_box(x, ..., t_end = 100, res = 0.01)
-\method{one_box}{numeric}(x, t_end = 100, res = 0.01, ...)
+\method{one_box}{numeric}(x, ..., t_end = 100, res = 0.01)
-\method{one_box}{character}(x, parms, t_end = 100, res = 0.01, ...)
+\method{one_box}{character}(x, parms, ..., t_end = 100, res = 0.01)
-\method{one_box}{mkinfit}(x, t_end = 100, res = 0.01, ...)
+\method{one_box}{mkinfit}(x, ..., t_end = 100, res = 0.01)
}
\arguments{
\item{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}
+\item{...}{Further arguments passed to methods}
+
\item{t_end}{End of the time series}
\item{res}{Resolution of the time series}
-\item{...}{Further arguments passed to methods}
-
\item{parms}{A named numeric vector containing the model parameters}
}
\description{
diff --git a/man/plot.one_box.Rd b/man/plot.one_box.Rd
index e2c9a42..69ee908 100644
--- a/man/plot.one_box.Rd
+++ b/man/plot.one_box.Rd
@@ -38,6 +38,7 @@ plot(sawtooth(dfop_pred, 3, 7), max_twa = 21)
# 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")
}

Contact - Imprint