aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/twa.R19
-rw-r--r--docs/reference/plot.one_box-2.pngbin10136 -> 11641 bytes
-rw-r--r--docs/reference/plot.one_box.html12
-rw-r--r--docs/reference/sawtooth.html2
-rw-r--r--man/plot.one_box.Rd7
-rw-r--r--man/sawtooth.Rd2
6 files changed, 29 insertions, 13 deletions
diff --git a/R/twa.R b/R/twa.R
index e14318f..59e15f9 100644
--- a/R/twa.R
+++ b/R/twa.R
@@ -84,7 +84,7 @@ one_box.mkinfit <- function(x, t_end = 100, res = 0.01, ...) {
}
#' Plot time series of decline data
-#'
+#'
#' @param x The object of type \code{\link{one_box}} to be plotted
#' @param xlim Limits for the x axis
#' @param ylim Limits for the y axis
@@ -96,10 +96,13 @@ one_box.mkinfit <- function(x, t_end = 100, res = 0.01, ...) {
#' be shown if max_twa is not NULL.
#' @param ... Further arguments passed to methods
#' @importFrom stats plot.ts
+#' @seealso \code{\link{sawtooth}}
#' @export
#' @examples
-#' plot(sawtooth(one_box(10), 3, 7), max_twa = 21)
-plot.one_box <- function(x,
+#' fomc_fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE)
+#' fomc_pred <- one_box(fomc_fit)
+#' plot(sawtooth(fomc_pred, 3, 7), max_twa = 21)
+plot.one_box <- function(x,
xlim = range(time(x)), ylim = c(0, max(x)),
xlab = "Time", ylab = "Fraction of initial",
max_twa = NULL, max_twa_var = dimnames(x)[[2]][1], ...)
@@ -111,7 +114,7 @@ plot.one_box <- function(x,
if (!is.null(max_twa)) {
x_twa <- max_twa(x, window = max_twa)
value <- x_twa$max[max_twa_var]
- rect(x_twa$window_start[max_twa_var], 0,
+ rect(x_twa$window_start[max_twa_var], 0,
x_twa$window_end[max_twa_var], value, col = "grey")
text(x_twa$window_end[max_twa_var], value, paste("Maximum:", signif(value, 3)), pos = 4)
# Plot a second time to cover the grey rectangle
@@ -126,7 +129,7 @@ plot.one_box <- function(x,
#' times, with an interval \code{i}.
#' @param x A \code{\link{one_box}} object
#' @param n The number of applications. If \code{applications} is specified, \code{n} is not used
-#' @param i The interval between applications. If \code{applications} is specified, \code{i}
+#' @param i The interval between applications. If \code{applications} is specified, \code{i}
#' is not used
#' @param applications A data frame holding the application times in the first column and
#' the corresponding amounts applied in the second column for each application cycle.
@@ -144,8 +147,8 @@ plot.one_box <- function(x,
#' plot(pred_2_saw, max_twa = 21, max_twa_var = "m1")
#'
#' max_twa(pred_2_saw)
-sawtooth <- function(x, n = 1, i = 365,
- applications = data.frame(time = seq(0, 0 + n * i, length.out = n),
+sawtooth <- function(x, n = 1, i = 365,
+ applications = data.frame(time = seq(0, 0 + n * i, length.out = n),
amount = 1))
{
n_obs = ncol(as.matrix(x))
@@ -199,7 +202,7 @@ twa.one_box <- function(x, window = 21)
}
#' The maximum time weighted average concentration for a moving window
-#'
+#'
#' @seealso \code{\link{twa}}
#' @inheritParams twa
#' @export
diff --git a/docs/reference/plot.one_box-2.png b/docs/reference/plot.one_box-2.png
index 4007876..1941d44 100644
--- a/docs/reference/plot.one_box-2.png
+++ b/docs/reference/plot.one_box-2.png
Binary files differ
diff --git a/docs/reference/plot.one_box.html b/docs/reference/plot.one_box.html
index 1870a55..235fb80 100644
--- a/docs/reference/plot.one_box.html
+++ b/docs/reference/plot.one_box.html
@@ -100,15 +100,23 @@ be shown if max_twa is not NULL.</dd>
<dd>Further arguments passed to methods</dd>
</dl>
+ <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
+
+ <p><code><a href='sawtooth.html'>sawtooth</a></code></p>
+
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
- <pre class="examples"><div class='input'><span class='fu'>plot</span>(<span class='fu'><a href='sawtooth.html'>sawtooth</a></span>(<span class='fu'><a href='one_box.html'>one_box</a></span>(<span class='fl'>10</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-2.png' alt='' width='540' height='400' /></pre>
+ <pre class="examples"><div class='input'><span class='no'>fomc_fit</span> <span class='kw'>&lt;-</span> <span class='fu'>mkinfit</span>(<span class='st'>"FOMC"</span>, <span class='no'>FOCUS_2006_C</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
+<span class='no'>fomc_pred</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='one_box.html'>one_box</a></span>(<span class='no'>fomc_fit</span>)
+<span class='fu'>plot</span>(<span class='fu'><a href='sawtooth.html'>sawtooth</a></span>(<span class='no'>fomc_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-2.png' alt='' width='540' height='400' /></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#arguments">Arguments</a></li>
-
+
+ <li><a href="#see-also">See also</a></li>
+
<li><a href="#examples">Examples</a></li>
</ul>
diff --git a/docs/reference/sawtooth.html b/docs/reference/sawtooth.html
index e24186e..cd3c0dc 100644
--- a/docs/reference/sawtooth.html
+++ b/docs/reference/sawtooth.html
@@ -85,7 +85,7 @@ times, with an interval <code>i</code>.</p>
<dt>n</dt>
<dd>The number of applications. If <code>applications</code> is specified, <code>n</code> is not used</dd>
<dt>i</dt>
- <dd>The interval between applications. If <code>applications</code> is specified, <code>i</code>
+ <dd>The interval between applications. If <code>applications</code> is specified, <code>i</code>
is not used</dd>
<dt>applications</dt>
<dd>A data frame holding the application times in the first column and
diff --git a/man/plot.one_box.Rd b/man/plot.one_box.Rd
index 7d30bd2..6245b4c 100644
--- a/man/plot.one_box.Rd
+++ b/man/plot.one_box.Rd
@@ -31,5 +31,10 @@ be shown if max_twa is not NULL.}
Plot time series of decline data
}
\examples{
-plot(sawtooth(one_box(10), 3, 7), max_twa = 21)
+fomc_fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE)
+fomc_pred <- one_box(fomc_fit)
+plot(sawtooth(fomc_pred, 3, 7), max_twa = 21)
+}
+\seealso{
+\code{\link{sawtooth}}
}
diff --git a/man/sawtooth.Rd b/man/sawtooth.Rd
index d26c0bf..e01a74d 100644
--- a/man/sawtooth.Rd
+++ b/man/sawtooth.Rd
@@ -12,7 +12,7 @@ sawtooth(x, n = 1, i = 365, applications = data.frame(time = seq(0, 0 + n
\item{n}{The number of applications. If \code{applications} is specified, \code{n} is not used}
-\item{i}{The interval between applications. If \code{applications} is specified, \code{i}
+\item{i}{The interval between applications. If \code{applications} is specified, \code{i}
is not used}
\item{applications}{A data frame holding the application times in the first column and

Contact - Imprint