Skip to content

Commit

Permalink
making sure the right incidence is attached to the object
Browse files Browse the repository at this point in the history
  • Loading branch information
thibautjombart committed Dec 5, 2017
1 parent b8cd1d6 commit 60c9046
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 7 deletions.
17 changes: 15 additions & 2 deletions R/get_R.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
#' \code{as.data.frame} to double-check that the epicurve includes the last
#' 'zeros'.
#'
#' @return A list with the \code{earlyR} class, containing the following
#' components:
#' \itemize{
#' \item
#'
#' \item
#'
#' \item
#'
#' }
#'
#' @examples
#'
#' if (require(incidence)) {
Expand All @@ -35,7 +46,7 @@
#' x
#' as.data.frame(x)
#' plot(x)
#' res <- get_R(x)
#' res <- get_R(x, disease = "ebola")
#' res
#' plot(res)
#' plot(res, "lambdas")
Expand Down Expand Up @@ -186,7 +197,8 @@ get_R.integer <- function(x, disease = NULL, si = NULL,
#' @aliases get_R.numeric

get_R.numeric <- function(x, ...) {
get_R(as.integer(x), ...)
out <- get_R(as.integer(x), ...)
out$incidence <- x
}


Expand Down Expand Up @@ -219,5 +231,6 @@ get_R.incidence <- function(x, ...) {
out$dates <- min(x$dates) - 1 + out$dates
}

out$incidence <- x
return(out)
}
17 changes: 16 additions & 1 deletion R/plot.earlyR.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,22 @@
#'
#' @param ... Further arguments to be passed to other methods (not used).
#'

#' if (require(incidence)) {
#'
#' ## example: onsets on days 1, 5, 6 and 12; estimation on day 24
#' onset <- c(1, 5, 6, 12)
#' x <- incidence(onset, last_date = 24)
#' x
#'
#' res <- get_R(x, disease = "ebola")
#' res
#' plot(res)
#' plot(res, "lambdas")
#' plot(res, "lambdas", scaling = 5)
#' points(onset, 1:4, cex = 3, pch = 20)
#'
#' }
#
plot.earlyR <- function(x, type = c("R", "lambdas"), scale = 1, ...) {

type <- match.arg(type)
Expand Down
2 changes: 1 addition & 1 deletion R/sample_R.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' if (require(incidence)) {
#' x <- incidence(c(1, 5, 5, 12, 45, 65))
#' plot(x)
#' res <- get_R(x)
#' res <- get_R(x, disease = "ebola")
#' res
#' plot(res)
#'
Expand Down
2 changes: 1 addition & 1 deletion man/get_R.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion man/plot.earlyR.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/sample_R.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified tests/testthat/rds/R_1.rds
Binary file not shown.

0 comments on commit 60c9046

Please sign in to comment.