Skip to content

Commit

Permalink
Update docs, skip some plot tests if R < 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hillalex committed Nov 19, 2024
1 parent c9cf348 commit 88d1b5e
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 5 deletions.
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method(plot,biokinetics_individual_trajectories)
S3method(plot,biokinetics_population_stationary_points)
S3method(plot,biokinetics_population_trajectories)
S3method(plot,biokinetics_priors)
export(add_exposure_data)
Expand All @@ -18,12 +20,19 @@ importFrom(data.table,.SD)
importFrom(data.table,data.table)
importFrom(ggplot2,aes)
importFrom(ggplot2,facet_wrap)
importFrom(ggplot2,geom_hline)
importFrom(ggplot2,geom_line)
importFrom(ggplot2,geom_path)
importFrom(ggplot2,geom_point)
importFrom(ggplot2,geom_ribbon)
importFrom(ggplot2,geom_smooth)
importFrom(ggplot2,geom_vline)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,guide_legend)
importFrom(ggplot2,guides)
importFrom(ggplot2,labs)
importFrom(ggplot2,scale_x_continuous)
importFrom(ggplot2,scale_x_date)
importFrom(ggplot2,scale_y_continuous)
importFrom(ggplot2,sec_axis)
useDynLib(epikinetics, .registration = TRUE)
4 changes: 3 additions & 1 deletion R/epikinetics-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#' @importFrom data.table .NGRP
#' @importFrom data.table .SD
#' @importFrom data.table data.table
#' @importFrom ggplot2 aes facet_wrap geom_point geom_ribbon geom_line geom_smooth ggplot guides guide_legend scale_y_continuous
#' @importFrom ggplot2 aes facet_wrap geom_point geom_ribbon geom_line geom_smooth
#' geom_vline geom_hline geom_path labs ggplot guides guide_legend scale_y_continuous
#' scale_x_continuous scale_x_date sec_axis
#' @useDynLib epikinetics, .registration = TRUE
## usethis namespace: end

Expand Down
19 changes: 16 additions & 3 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ plot.biokinetics_population_trajectories <- function(x, ..., data = NULL) {

# Declare variables to suppress notes when compiling package
# https://github.com/Rdatatable/data.table/issues/850#issuecomment-259466153
time_since_last_exp <- value <- me <- titre_type <- lo <- hi <- NULL
time_since_last_exp <- value <- me <- mu <- .draw <- titre_type <- lo <- hi <- NULL
day <- last_exp_day <- NULL

if (attr(x, "summarised")) {
Expand Down Expand Up @@ -124,7 +124,7 @@ plot.biokinetics_population_trajectories <- function(x, ..., data = NULL) {
#' generated by running biokinetics$simulate_individual_trajectories(). See
#' \href{../../epikinetics/html/biokinetics.html#method-biokinetics-simulate_individaul_trajectories}{\code{biokinetics$simulate_individual_trajectories()}}
#' @param \dots Further arguments passed to the method.
#' @oaram min_day Optional minimum date
#' @param min_day Optional minimum date
#' @param max_day Optional maximum date
#' @param pid Optional vector of ids to plot simulated trajectories for a subset of individuals. Can only be used
#' if x has been generated with summarise=FALSE.
Expand All @@ -138,7 +138,9 @@ plot.biokinetics_individual_trajectories <- function(x, ..., data = NULL,

# Declare variables to suppress notes when compiling package
# https://github.com/Rdatatable/data.table/issues/850#issuecomment-259466153
calendar_day <- value <- me <- mu <- titre_type <- lo <- hi <- day <- pid <- NULL
calendar_day <- value <- me <- mu <- titre_type <- day <- pid <- NULL
ind_mu_sum <- lo <- hi <- NULL

if (is.null(min_day)) {
min_day <- min(x$calendar_day)
}
Expand Down Expand Up @@ -213,7 +215,18 @@ plot.biokinetics_individual_trajectories <- function(x, ..., data = NULL,
fill = "none")
}

#' Plot method for "biokinetics_population_stationary_points" class
#'
#' @param x An object of class "biokinetics_population_stationary_points". These are
#' generated by running biokinetics$population_stationary_points(). See
#' \href{../../epikinetics/html/biokinetics.html#method-biokinetics-population_stationary_points}{\code{biokinetics$population_stationary_points()}}
#' @param \dots Further arguments passed to the method.
#' @param upper_detection_limit Numeric. Optional upper detection limit. Will be plotted as a dotted line.
#' @export
plot.biokinetics_population_stationary_points <- function(x, ..., upper_detection_limit = NULL) {
# Declare variables to suppress notes when compiling package
# https://github.com/Rdatatable/data.table/issues/850#issuecomment-259466153
mu_p <- mu_s <- mu_p_me <- mu_s_me <- titre_type <- NULL
covariates <- attr(x, "covariates")
plot <- ggplot(data = x,
aes(x = mu_p, y = mu_s, colour = titre_type)) +
Expand Down
2 changes: 1 addition & 1 deletion man/biokinetics.Rd

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

35 changes: 35 additions & 0 deletions man/plot.biokinetics_individual_trajectories.Rd

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

20 changes: 20 additions & 0 deletions man/plot.biokinetics_population_stationary_points.Rd

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

3 changes: 3 additions & 0 deletions tests/testthat/test-plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ test_that("Can plot individual trajectories for specific pids with data and titr
})

test_that("Can plot stationary points", {
skip_if(getRversion() < 4.1)
# note that this is using a pre-fitted model with very few iterations, so the
# fits won't look very good
local_mocked_bindings(
Expand All @@ -231,6 +232,7 @@ test_that("Can plot stationary points", {
})

test_that("Can plot stationary points with no covariates", {
skip_if(getRversion() < 4.1)
# note that this is using a pre-fitted model with very few iterations, so the
# fits won't look very good
local_mocked_bindings(
Expand All @@ -244,6 +246,7 @@ test_that("Can plot stationary points with no covariates", {


test_that("Can plot stationary points with upper limit", {
skip_if(getRversion() < 4.1)
# note that this is using a pre-fitted model with very few iterations, so the
# fits won't look very good
local_mocked_bindings(
Expand Down

0 comments on commit 88d1b5e

Please sign in to comment.