Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensures required packages are in Imports section #774

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
9 changes: 7 additions & 2 deletions .github/workflows/scheduled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ jobs:
strategy:
fail-fast: false
matrix:
test-strategy: ["min_cohort", "min_isolated", "release", "max"]
pair:
- { test-strategy: "min_cohort", test-additional-repos: "" }
- { test-strategy: "min_isolated", test-additional-repos: "" }
- { test-strategy: "release", test-additional-repos: "" }
- { test-strategy: "max", test-additional-repos: "https://pharmaverse.r-universe.dev" }
uses: insightsengineering/r.pkg.template/.github/workflows/verdepcheck.yaml@main
name: Dependency Test - ${{ matrix.test-strategy }} 🔢
secrets:
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
GCHAT_WEBHOOK: ${{ secrets.GCHAT_WEBHOOK }}
with:
strategy: ${{ matrix.test-strategy }}
strategy: ${{ matrix.pair.test-strategy }}
additional-repos: ${{ matrix.pair.test-additional-repos }}
additional-env-vars: |
PKG_SYSREQS_DRY_RUN=true
branch-cleanup:
Expand Down
50 changes: 24 additions & 26 deletions DESCRIPTION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see changes in dependencies and I immediately think about verdepcheck. Can you please confirm that it is passing on this? If not - let's work on the deps versions.

This might need to wait for https://github.com/insightsengineering/teal.modules.general/pull/774/files#r1890465398

Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,30 @@ Depends:
teal.transform (>= 0.5.0.9015)
Copy link
Contributor Author

@averissimo averissimo Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Teal requirement needs to be bumped with insightsengineering/teal#1432

Possibly to teal (>= 0.15.2.9091),

Keeping conversation open until the PR is closed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approved that PR, so working on this PR can continue.

Imports:
checkmate (>= 2.1.0),
colourpicker,
dplyr (>= 1.0.5),
DT (>= 0.13),
forcats (>= 1.0.0),
generics,
ggExtra,
ggpmisc (>= 0.4.3),
ggpp,
ggrepel,
goftest,
grid,
gridExtra,
htmlwidgets,
jsonlite,
lattice (>= 0.18-4),
MASS,
rtables (>= 0.6.8),
llrs-roche marked this conversation as resolved.
Show resolved Hide resolved
lifecycle (>= 0.2.0),
scales,
shinyjs,
shinyTree (>= 0.2.8),
shinyvalidate,
shinyWidgets (>= 0.5.1),
sparkline,
stats,
stringr (>= 1.4.1),
teal.code (>= 0.5.0.9012),
Expand All @@ -54,50 +68,34 @@ Imports:
tools,
utils
Suggests:
broom (>= 0.7.10),
colourpicker,
ggExtra,
ggpmisc (>= 0.4.3),
ggpp,
ggrepel,
goftest,
gridExtra,
htmlwidgets,
jsonlite,
knitr (>= 1.42),
lattice (>= 0.18-4),
logger (>= 0.2.0),
MASS,
nestcolor (>= 0.1.0),
pkgload,
rlang (>= 1.0.0),
rmarkdown (>= 2.23),
roxy.shinylive,
rtables (>= 0.6.8),
rvest,
shinytest2,
sparkline,
testthat (>= 3.1.9),
withr (>= 2.0.0)
VignetteBuilder:
knitr,
rmarkdown
Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2,
rstudio/shiny, insightsengineering/teal,
insightsengineering/teal.transform, mllg/checkmate, tidyverse/dplyr,
rstudio/DT, tidyverse/forcats, r-lib/lifecycle, r-lib/scales,
daattali/shinyjs, shinyTree/shinyTree, rstudio/shinyvalidate,
dreamRs/shinyWidgets, tidyverse/stringr,
Config/Needs/verdepcheck: tidyverse/ggplot2,
rstudio/shiny, insightsengineering/teal, insightsengineering/teal.transform,
mllg/checkmate, daattali/colourpicker, tidyverse/dplyr, rstudio/DT,
tidyverse/forcats, daattali/ggExtra, aphalo/ggpmisc, aphalo/ggpp,
slowkow/ggrepel, baddstats/goftest, ramnathv/htmlwidgets, jeroen/jsonlite,
deepayan/lattice, insightsengineering/rtables, r-lib/lifecycle,
r-lib/scales, daattali/shinyjs, shinyTree/shinyTree, rstudio/shinyvalidate,
dreamRs/shinyWidgets, htmlwidgets/sparkline, tidyverse/stringr,
insightsengineering/teal.code, insightsengineering/teal.data,
insightsengineering/teal.logger, insightsengineering/teal.reporter,
insightsengineering/teal.widgets, insightsengineering/tern,
tidyverse/tibble, tidyverse/tidyr, tidymodels/broom,
daattali/colourpicker, daattali/ggExtra, aphalo/ggpmisc, aphalo/ggpp,
slowkow/ggrepel, baddstats/goftest, ramnathv/htmlwidgets,
jeroen/jsonlite, yihui/knitr, daroczig/logger, deepayan/lattice,
tidyverse/tibble, tidyverse/tidyr, yihui/knitr, daroczig/logger,
insightsengineering/nestcolor, r-lib/pkgload, r-lib/rlang,
rstudio/rmarkdown, insightsengineering/roxy.shinylive,
insightsengineering/rtables, tidyverse/rvest, htmlwidgets/sparkline,
rstudio/rmarkdown, insightsengineering/roxy.shinylive, tidyverse/rvest,
rstudio/shinytest2, r-lib/testthat, r-lib/withr
Config/Needs/website: insightsengineering/nesttemplate
Encoding: UTF-8
Expand Down
18 changes: 4 additions & 14 deletions R/tm_g_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#' interactive <- function() TRUE
#' {{ next_example }}
# nolint start: line_length_linter.
#' @examplesIf require("ggpmisc", quietly = TRUE) && require("ggpp", quietly = TRUE) && require("goftest", quietly = TRUE) && require("MASS", quietly = TRUE) && require("broom", quietly = TRUE)
#' @examples
# nolint end: line_length_linter.
#' # general data example
#' data <- teal_data()
Expand Down Expand Up @@ -89,7 +89,7 @@
#' interactive <- function() TRUE
#' {{ next_example }}
# nolint start: line_length_linter.
#' @examplesIf require("ggpmisc", quietly = TRUE) && require("ggpp", quietly = TRUE) && require("goftest", quietly = TRUE) && require("MASS", quietly = TRUE) && require("broom", quietly = TRUE)
#' @examples
# nolint end: line_length_linter.
#' # CDISC data example
#' data <- teal_data()
Expand Down Expand Up @@ -154,16 +154,6 @@ tm_g_distribution <- function(label = "Distribution Module",
decorators = NULL) {
message("Initializing tm_g_distribution")

# Requires Suggested packages
extra_packages <- c("ggpmisc", "ggpp", "goftest", "MASS", "broom")
missing_packages <- Filter(function(x) !requireNamespace(x, quietly = TRUE), extra_packages)
if (length(missing_packages) > 0L) {
stop(sprintf(
"Cannot load package(s): %s.\nInstall or restart your session.",
toString(missing_packages)
))
}

# Normalize the parameters
if (inherits(dist_var, "data_extract_spec")) dist_var <- list(dist_var)
if (inherits(strata_var, "data_extract_spec")) strata_var <- list(strata_var)
Expand Down Expand Up @@ -1242,7 +1232,7 @@ srv_distribution <- function(id,
expr = {
test_table_data <- ANL %>%
dplyr::select(dist_var) %>%
with(., broom::glance(do.call(test, args))) %>%
with(., generics::glance(do.call(test, args))) %>%
dplyr::mutate_if(is.numeric, round, 3)
},
env = env
Expand All @@ -1256,7 +1246,7 @@ srv_distribution <- function(id,
test_table_data <- ANL %>%
dplyr::select(dist_var, s_var, g_var) %>%
dplyr::group_by_at(dplyr::vars(dplyr::any_of(groups))) %>%
dplyr::do(tests = broom::glance(do.call(test, args))) %>%
dplyr::do(tests = generics::glance(do.call(test, args))) %>%
tidyr::unnest(tests) %>%
dplyr::mutate_if(is.numeric, round, 3)
},
Expand Down
14 changes: 2 additions & 12 deletions R/tm_g_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#' interactive <- function() TRUE
#' {{ next_example }}
# nolint start: line_length_linter.
#' @examplesIf require("ggpmisc", quietly = TRUE) && require("ggExtra", quietly = TRUE) && require("colourpicker", quietly = TRUE)
#' @examples
# nolint end: line_length_linter.
#' # general data example
#' data <- teal_data()
Expand Down Expand Up @@ -134,7 +134,7 @@
#' interactive <- function() TRUE
#' {{ next_example }}
# nolint start: line_length_linter.
#' @examplesIf require("ggpmisc", quietly = TRUE) && require("ggExtra", quietly = TRUE) && require("colourpicker", quietly = TRUE)
#' @examples
# nolint end: line_length_linter.
#' # CDISC data example
#' data <- teal_data()
Expand Down Expand Up @@ -243,16 +243,6 @@ tm_g_scatterplot <- function(label = "Scatterplot",
decorators = NULL) {
message("Initializing tm_g_scatterplot")

# Requires Suggested packages
extra_packages <- c("ggpmisc", "ggExtra", "colourpicker")
missing_packages <- Filter(function(x) !requireNamespace(x, quietly = TRUE), extra_packages)
if (length(missing_packages) > 0L) {
stop(sprintf(
"Cannot load package(s): %s.\nInstall or restart your session.",
toString(missing_packages)
))
}

# Normalize the parameters
if (inherits(x, "data_extract_spec")) x <- list(x)
if (inherits(y, "data_extract_spec")) y <- list(y)
Expand Down
9 changes: 2 additions & 7 deletions R/tm_g_scatterplotmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#' library(teal.modules.general)
#' interactive <- function() TRUE
#' {{ next_example }}
#' @examplesIf require("lattice", quietly = TRUE)
#' @examples
#' # general data example
#' data <- teal_data()
#' data <- within(data, {
Expand Down Expand Up @@ -118,7 +118,7 @@
#' library(teal.modules.general)
#' interactive <- function() TRUE
#' {{ next_example }}
#' @examplesIf require("lattice", quietly = TRUE)
#' @examples
#' # CDISC data example
#' data <- teal_data()
#' data <- within(data, {
Expand Down Expand Up @@ -181,11 +181,6 @@ tm_g_scatterplotmatrix <- function(label = "Scatterplot Matrix",
decorators = NULL) {
message("Initializing tm_g_scatterplotmatrix")

# Requires Suggested packages
if (!requireNamespace("lattice", quietly = TRUE)) {
stop("Cannot load lattice - please install the package or restart your session.")
}

# Normalize the parameters
if (inherits(variables, "data_extract_spec")) variables <- list(variables)

Expand Down
92 changes: 47 additions & 45 deletions R/tm_missing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#' library(teal.modules.general)
#' interactive <- function() TRUE
#' {{ next_example }}
#' @examplesIf require("gridExtra", quietly = TRUE) && require("rlang", quietly = TRUE)
#' @examples
#' # general example data
#' data <- teal_data()
#' data <- within(data, {
Expand Down Expand Up @@ -85,7 +85,7 @@
#' library(teal.modules.general)
#' interactive <- function() TRUE
#' {{ next_example }}
#' @examplesIf require("gridExtra", quietly = TRUE) && require("rlang", quietly = TRUE)
#' @examples
#' # CDISC example data
#' data <- teal_data()
#' data <- within(data, {
Expand Down Expand Up @@ -121,14 +121,6 @@ tm_missing_data <- function(label = "Missing data",
decorators = NULL) {
message("Initializing tm_missing_data")

# Requires Suggested packages
if (!requireNamespace("gridExtra", quietly = TRUE)) {
stop("Cannot load gridExtra - please install the package or restart your session.")
}
if (!requireNamespace("rlang", quietly = TRUE)) {
stop("Cannot load rlang - please install the package or restart your session.")
}

# Normalize the parameters
if (inherits(ggplot2_args, "ggplot2_args")) ggplot2_args <- list(default = ggplot2_args)

Expand Down Expand Up @@ -1174,6 +1166,13 @@ srv_missing_data <- function(id,
ggtheme = input$ggtheme
)

# Unlikely that `rlang` is not available, new hashing may be expensive
hashing_function <- if (requireNamespace("rlang", quietly = TRUE)) {
quote(rlang::hash)
} else {
function(x) paste(as.integer(x), collapse = "")
averissimo marked this conversation as resolved.
Show resolved Hide resolved
}

teal.code::eval_code(
common_code_q(),
substitute(
Expand All @@ -1188,41 +1187,44 @@ srv_missing_data <- function(id,
)
) %>%
teal.code::eval_code(
quote({
summary_plot_patients <- ANL[, c(parent_keys, analysis_vars)] %>%
dplyr::group_by_at(parent_keys) %>%
dplyr::mutate(id = dplyr::cur_group_id()) %>%
dplyr::ungroup() %>%
dplyr::group_by_at(c(parent_keys, "id")) %>%
dplyr::summarise_all(anyNA) %>%
dplyr::ungroup()

# order subjects by decreasing number of missing and then by
# missingness pattern (defined using sha1)
order_subjects <- summary_plot_patients %>%
dplyr::select(-"id", -dplyr::all_of(parent_keys)) %>%
dplyr::transmute(
id = dplyr::row_number(),
number_NA = apply(., 1, sum),
sha = apply(., 1, rlang::hash)
) %>%
dplyr::arrange(dplyr::desc(number_NA), sha) %>%
getElement(name = "id")

# order columns by decreasing percent of missing values
ordered_columns <- summary_plot_patients %>%
dplyr::select(-"id", -dplyr::all_of(parent_keys)) %>%
dplyr::summarise(
column = create_cols_labels(colnames(.)),
na_count = apply(., MARGIN = 2, FUN = sum),
na_percent = na_count / nrow(.) * 100
) %>%
dplyr::arrange(na_percent, dplyr::desc(column))

summary_plot_patients <- summary_plot_patients %>%
tidyr::gather("col", "isna", -"id", -dplyr::all_of(parent_keys)) %>%
dplyr::mutate(col = create_cols_labels(col))
})
substitute(
expr = {
summary_plot_patients <- ANL[, c(parent_keys, analysis_vars)] %>%
dplyr::group_by_at(parent_keys) %>%
dplyr::mutate(id = dplyr::cur_group_id()) %>%
dplyr::ungroup() %>%
dplyr::group_by_at(c(parent_keys, "id")) %>%
dplyr::summarise_all(anyNA) %>%
dplyr::ungroup()

# order subjects by decreasing number of missing and then by
# missingness pattern (defined using sha1)
order_subjects <- summary_plot_patients %>%
dplyr::select(-"id", -dplyr::all_of(parent_keys)) %>%
dplyr::transmute(
id = dplyr::row_number(),
number_NA = apply(., 1, sum),
sha = apply(., 1, hashing_function)
) %>%
dplyr::arrange(dplyr::desc(number_NA), sha) %>%
getElement(name = "id")

# order columns by decreasing percent of missing values
ordered_columns <- summary_plot_patients %>%
dplyr::select(-"id", -dplyr::all_of(parent_keys)) %>%
dplyr::summarise(
column = create_cols_labels(colnames(.)),
na_count = apply(., MARGIN = 2, FUN = sum),
na_percent = na_count / nrow(.) * 100
) %>%
dplyr::arrange(na_percent, dplyr::desc(column))

summary_plot_patients <- summary_plot_patients %>%
tidyr::gather("col", "isna", -"id", -dplyr::all_of(parent_keys)) %>%
dplyr::mutate(col = create_cols_labels(col))
},
env = list(hashing_function = hashing_function)
)
) %>%
teal.code::eval_code(
substitute(
Expand Down
9 changes: 2 additions & 7 deletions R/tm_t_crosstable.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#' library(teal.modules.general)
#' interactive <- function() TRUE
#' {{ next_example }}
#' @examplesIf require("rtables", quietly = TRUE)
#' @examples
#' # general data example
#' data <- teal_data()
#' data <- within(data, {
Expand Down Expand Up @@ -87,7 +87,7 @@
#' library(teal.modules.general)
#' interactive <- function() TRUE
#' {{ next_example }}
#' @examplesIf require("rtables", quietly = TRUE)
#' @examples
#' # CDISC data example
#' data <- teal_data()
#' data <- within(data, {
Expand Down Expand Up @@ -147,11 +147,6 @@ tm_t_crosstable <- function(label = "Cross Table",
decorators = NULL) {
message("Initializing tm_t_crosstable")

# Requires Suggested packages
if (!requireNamespace("rtables", quietly = TRUE)) {
stop("Cannot load rtables - please install the package or restart your session.")
}

# Normalize the parameters
if (inherits(x, "data_extract_spec")) x <- list(x)
if (inherits(y, "data_extract_spec")) y <- list(y)
Expand Down
Loading
Loading