From f587aed75d566375b20ccdcd97ca2cb9c6e1f76b Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Tue, 10 Oct 2023 14:42:05 +0000 Subject: [PATCH 1/4] Remove multiplot --- NAMESPACE | 4 --- NEWS.md | 1 + R/helpers.R | 57 ------------------------------------------- _pkgdown.yaml | 1 - man/is.wholenumber.Rd | 20 +++++++++++++++ man/multiplot.Rd | 27 -------------------- man/safeInteger.Rd | 18 ++++++++++++++ 7 files changed, 39 insertions(+), 89 deletions(-) create mode 100644 man/is.wholenumber.Rd delete mode 100644 man/multiplot.Rd create mode 100644 man/safeInteger.Rd diff --git a/NAMESPACE b/NAMESPACE index 82edc104e..4a26ae6a1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -341,7 +341,6 @@ export(maxDose) export(maxSize) export(mcmc) export(minSize) -export(multiplot) export(nextBest) export(ngrid) export(plotDualResponses) @@ -521,9 +520,6 @@ importFrom(graphics,lines) importFrom(graphics,matlines) importFrom(graphics,matplot) importFrom(graphics,plot) -importFrom(grid,grid.newpage) -importFrom(grid,pushViewport) -importFrom(grid,viewport) importFrom(gridExtra,arrangeGrob) importFrom(kableExtra,add_footnote) importFrom(kableExtra,add_header_above) diff --git a/NEWS.md b/NEWS.md index 67e80121a..e0f4f21bf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,5 @@ # Version 1.0.9000.9133 +* Removed `multiplot` function. Use Please use equivalent functionality in other pakages, such as `cowplot` or `ggpubr`. * Added new `DataGrouped` and `DesignGrouped` classes with corresponding model `LogisticLogNormalGrouped` to support simultaneous dose escalation with monotherapy and combination therapy arms. * Created the `CrmPackClass` class as the ultimate ancestor of all other `crmPack` classes to allow identification of crmPack classes and simpler diff --git a/R/helpers.R b/R/helpers.R index 21273195d..3042e6816 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -219,63 +219,6 @@ crmPackHelp <- function() { utils::help(package = "crmPack", help_type = "html") } -#' Multiple plot function -#' -#' ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects). -#' If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), -#' then plot 1 will go in the upper left, 2 will go in the upper right, and -#' 3 will go all the way across the bottom. -#' -#' @param \dots Objects to be passed -#' @param plotlist a list of additional objects -#' @param rows Number of rows in layout -#' @param layout A matrix specifying the layout. If present, \code{rows} -#' is ignored. -#' -#' @return Used for the side effect of plotting -#' @importFrom grid grid.newpage pushViewport viewport -#' @export -multiplot <- function(..., plotlist = NULL, rows = 1, layout = NULL) { - # Make a list from the ... arguments and plotlist - plots <- c(list(...), plotlist) - - numPlots <- length(plots) - - # If layout is NULL, then use 'cols' to determine layout - if (is.null(layout)) { - # Make the panel - # ncol: Number of columns of plots - # nrow: Number of rows needed, calculated from # of cols - layout <- matrix(seq(1, rows * ceiling(numPlots / rows)), - nrow = rows, ncol = ceiling(numPlots / rows), - byrow = TRUE - ) - } - - if (numPlots == 1) { - print(plots[[1]]) - } else { - # Set up the page - grid::grid.newpage() - grid::pushViewport(grid::viewport(layout = grid::grid.layout( - nrow(layout), - ncol(layout) - ))) - - # Make each plot, in the correct location - for (i in seq_len(numPlots)) - { - # Get the i,j matrix positions of the regions that contain this subplot - matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE)) - - print(plots[[i]], vp = grid::viewport( - layout.pos.row = matchidx$row, - layout.pos.col = matchidx$col - )) - } - } -} - ##' Taken from utils package (print.vignette) ##' ##' @importFrom tools file_ext diff --git a/_pkgdown.yaml b/_pkgdown.yaml index 51bdc645a..9ec53f831 100644 --- a/_pkgdown.yaml +++ b/_pkgdown.yaml @@ -416,7 +416,6 @@ reference: - matchTolerance - maxSize - minSize - - multiplot - or-Stopping-Stopping - or-Stopping-StoppingAny - or-StoppingAny-Stopping diff --git a/man/is.wholenumber.Rd b/man/is.wholenumber.Rd new file mode 100644 index 000000000..1712f2f41 --- /dev/null +++ b/man/is.wholenumber.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\name{is.wholenumber} +\alias{is.wholenumber} +\title{checks for whole numbers (integers)} +\usage{ +is.wholenumber(x, tol = .Machine$double.eps^0.5) +} +\arguments{ +\item{x}{the numeric vector} + +\item{tol}{the tolerance} +} +\value{ +TRUE or FALSE for each element of x +} +\description{ +checks for whole numbers (integers) +} +\keyword{internal} diff --git a/man/multiplot.Rd b/man/multiplot.Rd deleted file mode 100644 index d8db664e0..000000000 --- a/man/multiplot.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R -\name{multiplot} -\alias{multiplot} -\title{Multiple plot function} -\usage{ -multiplot(..., plotlist = NULL, rows = 1, layout = NULL) -} -\arguments{ -\item{\dots}{Objects to be passed} - -\item{plotlist}{a list of additional objects} - -\item{rows}{Number of rows in layout} - -\item{layout}{A matrix specifying the layout. If present, \code{rows} -is ignored.} -} -\value{ -Used for the side effect of plotting -} -\description{ -ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects). -If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), -then plot 1 will go in the upper left, 2 will go in the upper right, and -3 will go all the way across the bottom. -} diff --git a/man/safeInteger.Rd b/man/safeInteger.Rd new file mode 100644 index 000000000..01ebec368 --- /dev/null +++ b/man/safeInteger.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\name{safeInteger} +\alias{safeInteger} +\title{Safe conversion to integer vector} +\usage{ +safeInteger(x) +} +\arguments{ +\item{x}{the numeric vector} +} +\value{ +the integer vector +} +\description{ +Safe conversion to integer vector +} +\keyword{internal} From 95aa3d054685ebe68a7bb1e1ad4c346fefbcec23 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Tue, 10 Oct 2023 14:43:07 +0000 Subject: [PATCH 2/4] Correct typo --- R/Rules-class.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/Rules-class.R b/R/Rules-class.R index 3ec8bd032..7eb04f1a7 100644 --- a/R/Rules-class.R +++ b/R/Rules-class.R @@ -2810,7 +2810,7 @@ CohortSizeDLT <- function(intervals, cohort_size) { #' @example examples/Rules-class-CohortSizeConst.R #' CohortSizeConst <- function(size) { - assert_integerish(size, min = 1) + assert_integerish(size, lower = 1) .CohortSizeConst(size = as.integer(size)) } @@ -2859,7 +2859,7 @@ CohortSizeConst <- function(size) { #' @example examples/Rules-class-CohortSizeParts.R #' CohortSizeParts <- function(cohort_sizes) { - assert_integerish(cohort_sizes, min = 1, any.missing = FALSE) + assert_integerish(cohort_sizes, lower = 1, any.missing = FALSE) .CohortSizeParts(cohort_sizes = as.integer(cohort_sizes)) } From 823173e69a32b034dd33e02bce209e21a009bc74 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Tue, 10 Oct 2023 14:59:12 +0000 Subject: [PATCH 3/4] Correcting typo in argument to assert_integerish --- R/Rules-class.R | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/R/Rules-class.R b/R/Rules-class.R index 7eb04f1a7..1736fe606 100644 --- a/R/Rules-class.R +++ b/R/Rules-class.R @@ -2698,7 +2698,8 @@ setClass( #' @example examples/Rules-class-CohortSizeRange.R #' CohortSizeRange <- function(intervals, cohort_size) { - assert_integerish(cohort_size, lower = 1, any.missing = FALSE) + # Cohort size 0 is needed to allow for no-placebo designs + assert_integerish(cohort_size, lower = 0, any.missing = FALSE) .CohortSizeRange( intervals = intervals, @@ -2759,7 +2760,8 @@ CohortSizeRange <- function(intervals, cohort_size) { #' CohortSizeDLT <- function(intervals, cohort_size) { assert_integerish(intervals, lower = 0, any.missing = FALSE) - assert_integerish(cohort_size, lower = 1, any.missing = FALSE) + # Cohort size 0 is needed to allow for no-placebo designs + assert_integerish(cohort_size, lower = 0, any.missing = FALSE) .CohortSizeDLT( intervals = as.integer(intervals), @@ -2810,7 +2812,8 @@ CohortSizeDLT <- function(intervals, cohort_size) { #' @example examples/Rules-class-CohortSizeConst.R #' CohortSizeConst <- function(size) { - assert_integerish(size, lower = 1) + # Cohort size 0 is needed to allow for no-placebo designs + assert_integerish(size, lower = 0) .CohortSizeConst(size = as.integer(size)) } @@ -2859,7 +2862,8 @@ CohortSizeConst <- function(size) { #' @example examples/Rules-class-CohortSizeParts.R #' CohortSizeParts <- function(cohort_sizes) { - assert_integerish(cohort_sizes, lower = 1, any.missing = FALSE) + # Cohort size 0 is needed to allow for no-placebo designs + assert_integerish(cohort_sizes, lower = 0, any.missing = FALSE) .CohortSizeParts(cohort_sizes = as.integer(cohort_sizes)) } From 8628b77f541bea7d4c0b54a209d457b87762d08c Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Tue, 10 Oct 2023 15:05:35 +0000 Subject: [PATCH 4/4] Correcting typo in NEWS.md --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index e0f4f21bf..66f5ee572 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ # Version 1.0.9000.9133 -* Removed `multiplot` function. Use Please use equivalent functionality in other pakages, such as `cowplot` or `ggpubr`. +* Removed `multiplot` function. Use Please use equivalent functionality in other packages, such as `cowplot` or `ggpubr`. * Added new `DataGrouped` and `DesignGrouped` classes with corresponding model `LogisticLogNormalGrouped` to support simultaneous dose escalation with monotherapy and combination therapy arms. * Created the `CrmPackClass` class as the ultimate ancestor of all other `crmPack` classes to allow identification of crmPack classes and simpler