Skip to content

Commit

Permalink
plot.diff_model() now allows users to trim how many simulated steps a…
Browse files Browse the repository at this point in the history
…re shown to only those leading up to complete infection
  • Loading branch information
jhollway committed Jun 21, 2024
1 parent 1b854dd commit fba9292
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/class_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ summary.diffs_model <- function(object, ...) {
#' @importFrom dplyr left_join
#' @importFrom ggplot2 geom_histogram
#' @export
plot.diff_model <- function(x, ...){
plot.diff_model <- function(x, ..., all = TRUE){
S <- E <- I <- I_new <- n <- R <- NULL # initialize variables to avoid CMD check notes
if(nrow(x)==1) warning("No diffusion observed.") else {
data <- x
if(!all) data <- data %>% dplyr::filter(!(data$I==data$n *
duplicated(data$I==data$n)))
p <- ggplot2::ggplot(data) +
ggplot2::geom_line(ggplot2::aes(x = t, y = S/n, color = "A"), linewidth = 1.25) +
ggplot2::geom_line(ggplot2::aes(x = t, y = I/n, color = "C"), linewidth = 1.25) +
Expand Down

0 comments on commit fba9292

Please sign in to comment.