diff --git a/NAMESPACE b/NAMESPACE index fb6c89134660871c733ae6be27362fa311c3f8ad..3025c5a46a4cf5b05253a8d3440ca124dca514b2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,9 +28,7 @@ export(recovery.FUN) export(seiqhrf) export(simulate_seiqhrf) export(vary_param) -import(dplyr) import(ggplot2) -import(lubridate) importFrom(EpiModel,get_prev.icm) importFrom(EpiModel,ssample) importFrom(EpiModel,verbose.icm) @@ -39,11 +37,13 @@ importFrom(dplyr,"%>%") importFrom(dplyr,between) importFrom(dplyr,bind_rows) importFrom(dplyr,filter) +importFrom(dplyr,full_join) importFrom(dplyr,mutate) importFrom(dplyr,select) importFrom(foreach,"%dopar%") importFrom(foreach,foreach) importFrom(future,availableCores) +importFrom(lubridate,ymd) importFrom(stats,pweibull) importFrom(stats,rbinom) importFrom(stats,rgeom) diff --git a/R/FIN_plot.R b/R/FIN_plot.R index 12331112c55e90f8e9e217eaf57b83395be3d1e3..508b8a6b4ab4a9223ec37ab8ee88b9626dfbd65a 100644 --- a/R/FIN_plot.R +++ b/R/FIN_plot.R @@ -32,7 +32,7 @@ #' @importFrom dplyr bind_rows #' @importFrom dplyr select #' @importFrom dplyr filter -#' @import lubridate +#' @importFrom lubridate ymd #' @import ggplot2 #' @export plot.seiqhrf <- function(x, method = NULL, @@ -104,7 +104,7 @@ plot.seiqhrf <- function(x, method = NULL, #' @importFrom dplyr bind_rows #' @importFrom dplyr select #' @importFrom dplyr filter -#' @import lubridate +#' @importFrom lubridate ymd #' @import ggplot2 #' @export plot.list <- function(x, comp_remove = "none", @@ -165,15 +165,15 @@ plot.list <- function(x, comp_remove = "none", #' @importFrom dplyr filter #' @import ggplot2 #' @export -plot_sirplus <- function(x, comp_remove = comp_remove, - time_lim = time_lim, - ci = ci, - sep_compartments = sep_compartments, - trans = trans, - known = known, - start_date = start_date, - x_axis = x_axis, - plot_title = plot_title, ...){ +plot_sirplus <- function(x, comp_remove, + time_lim, + ci, + sep_compartments, + trans, + known, + start_date, + x_axis, + plot_title, ...){ # Convert from seiqhrf object to dataframe plot_df <- format_sims(x, time_lim = time_lim, start_date = start_date) @@ -306,7 +306,7 @@ plot_times <- function(sim) { #' @return dataframe #' #' @export -format_sims <- function(x, time_lim = time_lim, start_date = start_date){ +format_sims <- function(x, time_lim, start_date){ # Merge models to plot together if(class(x) == "seiqhrf"){ @@ -343,11 +343,12 @@ format_sims <- function(x, time_lim = time_lim, start_date = start_date){ #' Get 95\% confidence intervals #' #' @param x An seiqhrf object returned from function \code{\link{seiqhrf}}. -#' @param known Dataframe with known compartment numbers to plot alongside +#' @param plot_df Dataframe with known compartment numbers to plot alongside #' projections #' #' @return dataframe with CIs and sd added #' @importFrom tidyr separate +#' @importFrom dplyr full_join #' #' @export #' @@ -404,22 +405,23 @@ get_ci <- function(x, plot_df){ ci_info[is.na(ci_info)] <- 0 plot_df <- plot_df %>% - full_join(ci_info, by = c('time', 'compartment', 'experiment', 'sim')) + dplyr::full_join(ci_info, by = c('time', 'compartment', 'experiment', 'sim')) return(plot_df) } #' Add known counts to sims dataframe for ggplot #' -#' @param x An seiqhrf object returned from function \code{\link{seiqhrf}}. +#' @param plot_df An seiqhrf object returned from function \code{\link{seiqhrf}}. #' @param known Dataframe with known compartment numbers to plot alongside #' projections +#' @param start_date Date for day 0. #' #' @return dataframe with known data added #' #' @export #' -add_known <- function(plot_df, known = known, start_date = start_date){ +add_known <- function(plot_df, known, start_date){ # Add Date to known data missing_cols <- setdiff(names(plot_df), names(known)) diff --git a/R/original_plot_models.R b/R/original_plot_models.R index 74a1a208ed2b4c2575587fa34c42cd3e2b0f4185..049b888b35caf2a4d8afcf57af2d1d1d8335f5a0 100644 --- a/R/original_plot_models.R +++ b/R/original_plot_models.R @@ -15,7 +15,6 @@ #' #' @return ggplot2 object #' -#' @import dplyr #' @importFrom tidyr pivot_longer plot_models <- function(sims = baseline_sim, diff --git a/man/add_known.Rd b/man/add_known.Rd index 5369f4e0d88fc08f4fb64a6050d196b128ddd8ec..2f3af39442191b452e1b46688be2a52a0fa2c403 100644 --- a/man/add_known.Rd +++ b/man/add_known.Rd @@ -4,13 +4,15 @@ \alias{add_known} \title{Add known counts to sims dataframe for ggplot} \usage{ -add_known(plot_df, known = known, start_date = start_date) +add_known(plot_df, known, start_date) } \arguments{ +\item{plot_df}{An seiqhrf object returned from function \code{\link{seiqhrf}}.} + \item{known}{Dataframe with known compartment numbers to plot alongside projections} -\item{x}{An seiqhrf object returned from function \code{\link{seiqhrf}}.} +\item{start_date}{Date for day 0.} } \value{ dataframe with known data added diff --git a/man/format_sims.Rd b/man/format_sims.Rd index 7bdc033949176ea8ac7687d2a1bdecafddc57c69..9a3735fe5f78df69313c25de7309c3735b8bd2e5 100644 --- a/man/format_sims.Rd +++ b/man/format_sims.Rd @@ -4,7 +4,7 @@ \alias{format_sims} \title{Format seiqhrf objects into dataframe for ggplot} \usage{ -format_sims(x, time_lim = time_lim, start_date = start_date) +format_sims(x, time_lim, start_date) } \arguments{ \item{x}{An seiqhrf object returned from function \code{\link{seiqhrf}}.} diff --git a/man/get_ci.Rd b/man/get_ci.Rd index 005e0afef4d41b4ee601f08207697e1f2a79bfec..faee92f94be6ef68d9554f9669bfc3e608e9a387 100644 --- a/man/get_ci.Rd +++ b/man/get_ci.Rd @@ -9,7 +9,7 @@ get_ci(x, plot_df) \arguments{ \item{x}{An seiqhrf object returned from function \code{\link{seiqhrf}}.} -\item{known}{Dataframe with known compartment numbers to plot alongside +\item{plot_df}{Dataframe with known compartment numbers to plot alongside projections} } \value{ diff --git a/man/plot_sirplus.Rd b/man/plot_sirplus.Rd index 408aa3b6c18e0d3cebd59221dd71ef9fc8e9cc41..24e9f704c85ec887a6e5ac8810523f07de4260c9 100644 --- a/man/plot_sirplus.Rd +++ b/man/plot_sirplus.Rd @@ -6,15 +6,15 @@ \usage{ plot_sirplus( x, - comp_remove = comp_remove, - time_lim = time_lim, - ci = ci, - sep_compartments = sep_compartments, - trans = trans, - known = known, - start_date = start_date, - x_axis = x_axis, - plot_title = plot_title, + comp_remove, + time_lim, + ci, + sep_compartments, + trans, + known, + start_date, + x_axis, + plot_title, ... ) }