From 335f74e69b960cc817ae9df0c87ba4c9448729fc Mon Sep 17 00:00:00 2001 From: Konrad Rudolph Date: Thu, 8 Feb 2024 15:53:57 +0100 Subject: [PATCH 1/5] Replace obsolete links --- R/utils-tidy-eval.R | 2 +- README.Rmd | 2 +- README.md | 2 +- man/tidyeval.Rd | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/utils-tidy-eval.R b/R/utils-tidy-eval.R index 566f871e..6bb9759e 100644 --- a/R/utils-tidy-eval.R +++ b/R/utils-tidy-eval.R @@ -34,7 +34,7 @@ #' name, or would like to enforce this, use \code{as_name()}. #' #' To learn more about tidy eval and how to use these tools, visit -#' \url{https://tidyeval.tidyverse.org} and the +#' \url{https://dplyr.tidyverse.org/articles/programming.html} and the #' \href{https://adv-r.hadley.nz/metaprogramming.html}{Metaprogramming #' section} of \href{https://adv-r.hadley.nz}{Advanced R}. #' diff --git a/README.Rmd b/README.Rmd index d393fcac..ff746434 100644 --- a/README.Rmd +++ b/README.Rmd @@ -36,7 +36,7 @@ devtools::install_github("BEDApub/designit") ## Usage ### R in Pharma presentation -[![Designit: a flexible engine to generate experiment layouts, R in Pharma presentation](https://img.youtube.com/vi/mvPmSQJVy8o/0.jpg)](http://www.youtube.com/watch?v=mvPmSQJVy8o "Designit: a flexible engine to generate experiment layouts") +[![Designit: a flexible engine to generate experiment layouts, R in Pharma presentation](https://img.youtube.com/vi/mvPmSQJVy8o/0.jpg)](https://www.youtube.com/watch?v=mvPmSQJVy8o "Designit: a flexible engine to generate experiment layouts") ### Batch container The main class used is `BatchContainer`, which holds the dimensions for sample allocation. diff --git a/README.md b/README.md index 76d06e19..a9001ce5 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ devtools::install_github("BEDApub/designit") ## Usage ### R in Pharma presentation -[![Designit: a flexible engine to generate experiment layouts, R in Pharma presentation](https://img.youtube.com/vi/mvPmSQJVy8o/0.jpg)](http://www.youtube.com/watch?v=mvPmSQJVy8o "Designit: a flexible engine to generate experiment layouts") +[![Designit: a flexible engine to generate experiment layouts, R in Pharma presentation](https://img.youtube.com/vi/mvPmSQJVy8o/0.jpg)](https://www.youtube.com/watch?v=mvPmSQJVy8o "Designit: a flexible engine to generate experiment layouts") ### Batch container The main class used is `BatchContainer`, which holds the dimensions for diff --git a/man/tidyeval.Rd b/man/tidyeval.Rd index af0f2170..af5f5af7 100644 --- a/man/tidyeval.Rd +++ b/man/tidyeval.Rd @@ -43,7 +43,7 @@ name, or would like to enforce this, use \code{as_name()}. } To learn more about tidy eval and how to use these tools, visit -\url{https://tidyeval.tidyverse.org} and the +\url{https://dplyr.tidyverse.org/articles/programming.html} and the \href{https://adv-r.hadley.nz/metaprogramming.html}{Metaprogramming section} of \href{https://adv-r.hadley.nz}{Advanced R}. } From 2c2f6458a26c9d64ca57c2083c6e90cff05f8643 Mon Sep 17 00:00:00 2001 From: Konrad Rudolph Date: Thu, 8 Feb 2024 15:57:32 +0100 Subject: [PATCH 2/5] Fix spurious unused dependency CRAN note --- NAMESPACE | 1 + R/batch_container.R | 1 + 2 files changed, 2 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index e8a9d03c..b6f427c3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -41,6 +41,7 @@ export(sum_scores) export(sym) export(syms) export(worst_score) +import(R6, except = getNamespaceExports("R6")) importFrom(magrittr,"%>%") importFrom(rlang,.data) importFrom(rlang,as_label) diff --git a/R/batch_container.R b/R/batch_container.R index f2983c03..66c68398 100644 --- a/R/batch_container.R +++ b/R/batch_container.R @@ -122,6 +122,7 @@ locations_table_from_dimensions <- function(dimensions, exclude) { #' A typical workflow starts with creating a `BatchContainer`. Then #' samples can be assigned to locations in that container. #' +#' @rawNamespace import(R6, except = getNamespaceExports("R6")) #' @export BatchContainer <- R6::R6Class("BatchContainer", public = list( From 44b5c9ff5d654c6ac86adde0e1a60e86bc7e1fa2 Mon Sep 17 00:00:00 2001 From: Konrad Rudolph Date: Fri, 9 Feb 2024 10:45:59 +0100 Subject: [PATCH 3/5] Reduce package bundle size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip a large vignette (“Plate scoring examples”) on CRAN, and reduce some image sizes of the “Plate layouts” example. --- .Rbuildignore | 4 ++++ DESCRIPTION | 2 +- vignettes/plate_layouts.Rmd | 10 +++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 38817bdf..9ead1eaa 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,5 @@ +^renv$ +^renv\.lock$ ^designit\.Rproj$ ^\.Rproj\.user$ ^LICENSE\.md$ @@ -19,3 +21,5 @@ # vignette cache ^vignettes/cached/.*\.Rmd$ +# large vignette excluded on CRAN +^vignettes/plate_scoring_examples.Rmd$ diff --git a/DESCRIPTION b/DESCRIPTION index c0cca1e0..2e47a88b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -74,6 +74,6 @@ Suggests: Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 VignetteBuilder: knitr biocViews: diff --git a/vignettes/plate_layouts.Rmd b/vignettes/plate_layouts.Rmd index b2c81095..f2a6e31f 100644 --- a/vignettes/plate_layouts.Rmd +++ b/vignettes/plate_layouts.Rmd @@ -327,7 +327,7 @@ cowplot::plot_grid( ) ``` -```{r fig.width=9, fig.height=3} +```{r fig.width=5.5, fig.height=2} bc$scores_table() |> ggplot(aes(step, value, color = score)) + geom_line() + @@ -398,7 +398,7 @@ scoring_f <- list( bc <- assign_random(bc, subjects) ``` -```{r, fig.width= 8, fig.height=3} +```{r, fig.width= 5, fig.height=2} cowplot::plot_grid( plotlist = list( bc$get_samples() %>% ggplot(aes(x = plate, fill = Group)) + @@ -495,7 +495,7 @@ bc$get_samples() %>% unlist() ``` -```{r, fig.width= 8, fig.height=10} +```{r, fig.width= 5, fig.height=6.25} cowplot::plot_grid( plotlist = list( plot_plate(bc, @@ -533,7 +533,7 @@ bc <- optimize_multi_plate_design(bc, ) ``` -```{r, fig.width= 8, fig.height=10} +```{r, fig.width= 5, fig.height=6.25} cowplot::plot_grid( plotlist = list( plot_plate(bc, @@ -555,7 +555,7 @@ cowplot::plot_grid( ``` -```{r fig.width=6, fig.height=5} +```{r fig.width=6, fig.height=4} bc$scores_table() |> ggplot(aes(step, value, color = score)) + geom_line() + From 2fa411cf72ae97a1da034159a2bf90f7a57278e8 Mon Sep 17 00:00:00 2001 From: Balazs Banfai Date: Fri, 9 Feb 2024 14:37:59 +0100 Subject: [PATCH 4/5] Fix documentation of .datatable.aware --- R/utils-datatable.R | 16 ++++++++-------- man/dot-datatable.aware.Rd | 20 ++++---------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/R/utils-datatable.R b/R/utils-datatable.R index e20d5f91..f3b4737d 100644 --- a/R/utils-datatable.R +++ b/R/utils-datatable.R @@ -1,10 +1,10 @@ -#' This undocumented (?) flag allows us to use `:=` -#' without getting an error. -#' @keywords internal +#' Show that the package is designed to rely on data.table functionality +#' +#' See [data.table::let()] and +#' [`vignette("datatable-importing", "data.table")`](https://cran.r-project.org/web/packages/data.table/vignettes/datatable-importing.html) +#' section "data.table in Imports but nothing imported". #' -#' @examples -#' \dontrun{ -#' dt <- data.table::data.table(a = 1, b = 2) -#' dt[, a := NULL] -#' } +#' @keywords internal +#' @usage NULL +#' @format NULL .datatable.aware <- TRUE diff --git a/man/dot-datatable.aware.Rd b/man/dot-datatable.aware.Rd index 025f1698..70c89f3c 100644 --- a/man/dot-datatable.aware.Rd +++ b/man/dot-datatable.aware.Rd @@ -3,22 +3,10 @@ \docType{data} \name{.datatable.aware} \alias{.datatable.aware} -\title{This undocumented (?) flag allows us to use \verb{:=} -without getting an error.} -\format{ -An object of class \code{logical} of length 1. -} -\usage{ -.datatable.aware -} +\title{Show that the package is designed to rely on data.table functionality} \description{ -This undocumented (?) flag allows us to use \verb{:=} -without getting an error. -} -\examples{ -\dontrun{ -dt <- data.table::data.table(a = 1, b = 2) -dt[, a := NULL] -} +See \code{\link[data.table:assign]{data.table::let()}} and +\href{https://cran.r-project.org/web/packages/data.table/vignettes/datatable-importing.html}{\code{vignette("datatable-importing", "data.table")}} +section "data.table in Imports but nothing imported". } \keyword{internal} From 16564a87346f41c5966ecdac2d85625fcfa7c082 Mon Sep 17 00:00:00 2001 From: Balazs Banfai Date: Fri, 9 Feb 2024 14:51:16 +0100 Subject: [PATCH 5/5] Remove utils-tidy-eval * it's deprecated * keep importing .data, because we use it --- NAMESPACE | 15 ------------- R/assignment.R | 4 ++-- R/designit-package.R | 4 ++++ R/randomization.R | 4 ++-- R/utils-tidy-eval.R | 47 ----------------------------------------- man/tidyeval.Rd | 50 -------------------------------------------- 6 files changed, 8 insertions(+), 116 deletions(-) delete mode 100644 R/utils-tidy-eval.R delete mode 100644 man/tidyeval.Rd diff --git a/NAMESPACE b/NAMESPACE index b6f427c3..c514f88b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,14 +1,11 @@ # Generated by roxygen2: do not edit by hand export("%>%") -export(.data) export(BatchContainer) export(BatchContainerDimension) export(L1_norm) export(L2s_norm) export(accept_leftmost_improvement) -export(as_label) -export(as_name) export(assign_from_table) export(assign_in_order) export(assign_random) @@ -16,9 +13,6 @@ export(batch_container_from_table) export(compile_possible_subgroup_allocation) export(complete_random_shuffling) export(drop_order) -export(enquo) -export(enquos) -export(expr) export(first_score_only) export(form_homogeneous_subgroups) export(generate_terms) @@ -38,17 +32,8 @@ export(shuffle_grouped_data) export(shuffle_with_constraints) export(shuffle_with_subgroup_formation) export(sum_scores) -export(sym) -export(syms) export(worst_score) import(R6, except = getNamespaceExports("R6")) importFrom(magrittr,"%>%") importFrom(rlang,.data) -importFrom(rlang,as_label) -importFrom(rlang,as_name) -importFrom(rlang,enquo) -importFrom(rlang,enquos) -importFrom(rlang,expr) -importFrom(rlang,sym) -importFrom(rlang,syms) importFrom(stats,na.omit) diff --git a/R/assignment.R b/R/assignment.R index c9a44f54..a8a8d6ce 100644 --- a/R/assignment.R +++ b/R/assignment.R @@ -72,8 +72,8 @@ assign_in_order <- function(batch_container, samples = NULL) { #' #' @example man/examples/shuffle_with_constraints.R shuffle_with_constraints <- function(src = TRUE, dst = TRUE) { - src <- enquo(src) - dst <- enquo(dst) + src <- rlang::enquo(src) + dst <- rlang::enquo(dst) function(bc, i) { dt <- bc$get_samples(include_id = TRUE, as_tibble = FALSE) src_ind <- which(rep_len(TRUE, nrow(dt)) & rlang::eval_tidy(src, dt)) diff --git a/R/designit-package.R b/R/designit-package.R index b30bbdac..db2f897d 100644 --- a/R/designit-package.R +++ b/R/designit-package.R @@ -1,6 +1,10 @@ #' @keywords internal "_PACKAGE" +# Manual imports +#' @importFrom rlang .data +NULL + # The following block is used by usethis to automatically manage # roxygen namespace tags. Modify with care! ## usethis namespace: start diff --git a/R/randomization.R b/R/randomization.R index 5d4fe66f..e148a0a6 100644 --- a/R/randomization.R +++ b/R/randomization.R @@ -96,10 +96,10 @@ getScore <- function(layout, balance, sc_groups, sc_tests, # get the penalty for each dimension group # factor von balace variables penalty <- layout %>% - dplyr::group_by(!!sym(group)) %>% + dplyr::group_by(!!rlang::sym(group)) %>% dplyr::summarize_at(.vars = dplyr::vars(balance), testFun) score <- penalty %>% - dplyr::summarize(score = sum((!!sym(balance))^2, na.rm = TRUE)) + dplyr::summarize(score = sum((!!rlang::sym(balance))^2, na.rm = TRUE)) score <- sum(score * bal_weights) # multiply score for each balance factor by its weight and sum tscore <- tscore + score } else { diff --git a/R/utils-tidy-eval.R b/R/utils-tidy-eval.R deleted file mode 100644 index 6bb9759e..00000000 --- a/R/utils-tidy-eval.R +++ /dev/null @@ -1,47 +0,0 @@ -#' Tidy eval helpers -#' -#' @description -#' -#' * \code{\link[rlang:quotation]{sym}()} creates a symbol from a string and -#' \code{\link[rlang:quotation]{syms}()} creates a list of symbols from a -#' character vector. -#' -#' * \code{\link[rlang:quotation]{enquo}()} and -#' \code{\link[rlang:quotation]{enquos}()} delay the execution of one or -#' several function arguments. \code{enquo()} returns a single quoted -#' expression, which is like a blueprint for the delayed computation. -#' \code{enquos()} returns a list of such quoted expressions. -#' -#' * \code{\link[rlang:quotation]{expr}()} quotes a new expression _locally_. It -#' is mostly useful to build new expressions around arguments -#' captured with [enquo()] or [enquos()]: -#' \code{expr(mean(!!enquo(arg), na.rm = TRUE))}. -#' -#' * \code{\link[rlang]{as_name}()} transforms a quoted variable name -#' into a string. Supplying something else than a quoted variable -#' name is an error. -#' -#' That's unlike \code{\link[rlang]{as_label}()} which also returns -#' a single string but supports any kind of R object as input, -#' including quoted function calls and vectors. Its purpose is to -#' summarise that object into a single label. That label is often -#' suitable as a default name. -#' -#' If you don't know what a quoted expression contains (for instance -#' expressions captured with \code{enquo()} could be a variable -#' name, a call to a function, or an unquoted constant), then use -#' \code{as_label()}. If you know you have quoted a simple variable -#' name, or would like to enforce this, use \code{as_name()}. -#' -#' To learn more about tidy eval and how to use these tools, visit -#' \url{https://dplyr.tidyverse.org/articles/programming.html} and the -#' \href{https://adv-r.hadley.nz/metaprogramming.html}{Metaprogramming -#' section} of \href{https://adv-r.hadley.nz}{Advanced R}. -#' -#' @md -#' @name tidyeval -#' @keywords internal -#' @importFrom rlang expr enquo enquos sym syms .data as_name as_label -#' @aliases expr enquo enquos sym syms .data as_name as_label -#' @export expr enquo enquos sym syms .data as_name as_label -NULL diff --git a/man/tidyeval.Rd b/man/tidyeval.Rd deleted file mode 100644 index af5f5af7..00000000 --- a/man/tidyeval.Rd +++ /dev/null @@ -1,50 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils-tidy-eval.R -\name{tidyeval} -\alias{tidyeval} -\alias{expr} -\alias{enquo} -\alias{enquos} -\alias{sym} -\alias{syms} -\alias{.data} -\alias{as_name} -\alias{as_label} -\title{Tidy eval helpers} -\description{ -\itemize{ -\item \code{\link[rlang:quotation]{sym}()} creates a symbol from a string and -\code{\link[rlang:quotation]{syms}()} creates a list of symbols from a -character vector. -\item \code{\link[rlang:quotation]{enquo}()} and -\code{\link[rlang:quotation]{enquos}()} delay the execution of one or -several function arguments. \code{enquo()} returns a single quoted -expression, which is like a blueprint for the delayed computation. -\code{enquos()} returns a list of such quoted expressions. -\item \code{\link[rlang:quotation]{expr}()} quotes a new expression \emph{locally}. It -is mostly useful to build new expressions around arguments -captured with \code{\link[=enquo]{enquo()}} or \code{\link[=enquos]{enquos()}}: -\code{expr(mean(!!enquo(arg), na.rm = TRUE))}. -\item \code{\link[rlang]{as_name}()} transforms a quoted variable name -into a string. Supplying something else than a quoted variable -name is an error. - -That's unlike \code{\link[rlang]{as_label}()} which also returns -a single string but supports any kind of R object as input, -including quoted function calls and vectors. Its purpose is to -summarise that object into a single label. That label is often -suitable as a default name. - -If you don't know what a quoted expression contains (for instance -expressions captured with \code{enquo()} could be a variable -name, a call to a function, or an unquoted constant), then use -\code{as_label()}. If you know you have quoted a simple variable -name, or would like to enforce this, use \code{as_name()}. -} - -To learn more about tidy eval and how to use these tools, visit -\url{https://dplyr.tidyverse.org/articles/programming.html} and the -\href{https://adv-r.hadley.nz/metaprogramming.html}{Metaprogramming -section} of \href{https://adv-r.hadley.nz}{Advanced R}. -} -\keyword{internal}