Skip to content

Commit

Permalink
Merge pull request #76 from metrumresearchgroup/release/0.3.7
Browse files Browse the repository at this point in the history
Release/0.3.7
  • Loading branch information
kylebaron authored Aug 14, 2023
2 parents dbcb989 + ee41766 commit a43543a
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 38 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: pmplots
Type: Package
Title: Plots for Pharmacometrics
Version: 0.3.6
Version: 0.3.7
Authors@R: c(
person("Kyle T", "Baron", "", "kyleb@metrumrg.com", c("aut", "cre")),
person("Metrum Research Group", role = c("cph"))
Expand Down Expand Up @@ -35,7 +35,7 @@ Suggests:
shiny,
rmarkdown
Depends: ggplot2 (>= 3.4.0)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
Collate:
'Aaaa.R'
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# pmplots 0.3.7

## Bugs fixed

- Fix bug where density line was not being drawn by default over npde and
cwres histograms; the bug came about from incomplete transition to
changes introduced in `ggplot2` v3.4.0 (#74, #75).

# pmplots 0.3.6

- Update plotting code to work with new `ggplot2` behavior introduced
Expand Down
28 changes: 14 additions & 14 deletions R/hist.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
##' Generate a histogram plot
##'
##' \code{cont_hist_list} is a vectorized version
##' of \code{cont_hist}. \code{pm_histogram} is a generic histogram
##' `cont_hist_list` is a vectorized version
##' of `cont_hist`. `pm_histogram` is a generic histogram
##' function that is called by other functions in pmplots.
##'
##' @param df the data frame containing plotting data
##' @param x the x column for \code{geom_histogram}
##' @param df the data frame containing plotting data.
##' @param x the x column for [ggplot2::geom_histogram()].
##' @param y what to use for the y-axis on the histogram; can be
##' \code{"count"} or \code{"density"}
##' @param add_density if \code{TRUE}, a normal density line will
##' be plotted over the histogram using \code{\link{add_density}}
##' @param xs a list of information for the x axis
##' @param fill a character value passed to \code{geom_histogram}
##' @param col a character value passed to \code{geom_histogram}
##' @param alpha a numeric value passed to \code{geom_histogram}
##' @param add_layers extra layers will be added only if \code{TRUE}
##' @param ... passed to \code{geom_histogram} and \code{add_density}
##' `"count"` or `"density"`.
##' @param add_density if `TRUE`, a normal density line will
##' be plotted over the histogram using [add_density()].
##' @param xs a list of information for the x axis.
##' @param fill a character value passed to [ggplot2::geom_histogram()].
##' @param col a character value passed to [ggplot2::geom_histogram()].
##' @param alpha a numeric value passed to [ggplot2::geom_histogram()].
##' @param add_layers extra layers will be added only if `TRUE`.
##' @param ... passed to [ggplot2::geom_histogram()] and [add_density()].
##'
##'
##' @examples
Expand All @@ -25,7 +25,7 @@
##' cont_hist(data, x = "WT//Weight (kg)")
##'
##' @return A single plot.
##'
##' @md
##' @export
cont_hist <- function(df, x, xs = defx(),
y = "count",
Expand Down
14 changes: 8 additions & 6 deletions R/res_hist.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
##' Histograms of residuals or NPDE
##'
##' @param df data frame to plot
##' @param ... passed to \code{\link{cont_hist}}
##' @param x character name for x-axis data
##' @param xs see \code{\link{defx}}
##' @param df data frame to plot.
##' @param ... passed to [cont_hist()]
##' @param x character name for x-axis data.
##' @param xs see [defx()].
##' @param y what to use for the y-axis on the histogram; can be
##' \code{"..count.."} or \code{"..density.."}
##' "count"` or `"density"`.
##'
##' @examples
##' df <- pmplots_data_obs()
Expand All @@ -14,6 +14,8 @@
##'
##' @return A single plot.
##'
##' @md
##'
##' @export
res_hist <- function(df, ...,
x = pm_axis_res(),
Expand All @@ -25,7 +27,7 @@ res_hist <- function(df, ...,
##' @rdname res_hist
wres_hist <- function(df, ...,
x = pm_axis_wres(),
y = "..density..") {
y = "density") {
res_hist(df, x = x, y = y, ...)
}

Expand Down
1 change: 1 addition & 0 deletions inst/validation/pmplots-stories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ PMP-S023:
- PMP-TEST-040
- PMP-TEST-041
- PMP-TEST-074
- PMP-TEST-089
PMP-S024:
name: List plots
description: As a user, I want to create list plots.
Expand Down
20 changes: 10 additions & 10 deletions man/cont_hist.Rd

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

12 changes: 6 additions & 6 deletions man/res_hist.Rd

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

16 changes: 16 additions & 0 deletions tests/testthat/test-pm.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,22 @@ test_that("res hist [PMP-TEST-041]", {
})


test_that("optional density plot over histogram [PMP-TEST-089]", {
# issue 74
x <- npde_hist(df)
expect_is(x, "gg")
expect_length(x$layers, 2)

y <- npde_hist(df, add_density = FALSE)
expect_length(y$layers, 1)

z <- cont_hist(df, x = "NPDE", add_density = TRUE)
expect_length(z$layers, 2)

w <- cont_hist(df, x = "WT", add_density = FALSE)
expect_length(w$layers, 1)
})

test_that("eta pairs [PMP-TEST-042]", {
p <- eta_pairs(df, c("ETA1//ETA-CL", "ETA2//ETA-V2"))
expect_is(p,"ggmatrix")
Expand Down

0 comments on commit a43543a

Please sign in to comment.