From 3d4f6f8c582c19c38587ead305a1229ff069da63 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 19 Jan 2017 08:24:44 +0100 Subject: 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 --- R/twa.R | 19 +++++++++++-------- docs/reference/plot.one_box-2.png | Bin 10136 -> 11641 bytes docs/reference/plot.one_box.html | 12 ++++++++++-- docs/reference/sawtooth.html | 2 +- man/plot.one_box.Rd | 7 ++++++- man/sawtooth.Rd | 2 +- 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 Binary files a/docs/reference/plot.one_box-2.png and b/docs/reference/plot.one_box-2.png 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.
Further arguments passed to methods
+

See also

+ +

sawtooth

+

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)