From 57a11220e4c7c610e60f8f5f7bb72fd94419ac49 Mon Sep 17 00:00:00 2001 From: Aleksander Chlebowski <114988527+chlebowa@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:32:46 +0100 Subject: [PATCH] 643 potential removal of dependencies (#663) Closes #643 --- .pre-commit-config.yaml | 1 - DESCRIPTION | 16 +++++++--------- NAMESPACE | 3 +-- R/teal.modules.general.R | 5 ++--- R/tm_a_pca.R | 4 ++-- R/tm_a_regression.R | 4 ++-- R/tm_data_table.R | 6 +++--- R/tm_front_page.R | 2 +- R/tm_g_association.R | 4 ++-- R/tm_g_bivariate.R | 4 ++-- R/tm_g_response.R | 4 ++-- R/tm_g_scatterplot.R | 4 ++-- R/tm_missing_data.R | 18 +++++++++--------- man/tm_a_pca.Rd | 4 ++-- man/tm_a_regression.Rd | 4 ++-- man/tm_data_table.Rd | 4 ++-- man/tm_front_page.Rd | 2 +- man/tm_g_association.Rd | 4 ++-- man/tm_g_bivariate.Rd | 4 ++-- man/tm_g_response.Rd | 4 ++-- man/tm_g_scatterplot.Rd | 4 ++-- man/tm_missing_data.Rd | 4 ++-- 22 files changed, 52 insertions(+), 57 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a80cd7b49..f10b1244e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,6 @@ repos: - tern - tibble - tidyr - - tidyselect - utils - id: spell-check diff --git a/DESCRIPTION b/DESCRIPTION index 9b2b532c9..2e5aafaed 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,9 +13,10 @@ Authors@R: c( person("Nikolas", "Burkoff", role = "aut"), person("F. Hoffmann-La Roche AG", role = c("cph", "fnd")) ) -Description: Prebuilt 'shiny' modules containing tools for viewing data, visualizing data, - understanding missing and outlier values within your data and performing simple data analysis. - This extends 'teal' framework that supports reproducible research and analysis. +Description: Prebuilt 'shiny' modules containing tools for viewing data, + visualizing data, understanding missing and outlier values within your + data and performing simple data analysis. This extends 'teal' + framework that supports reproducible research and analysis. License: Apache License 2.0 URL: https://insightsengineering.github.io/teal.modules.general/, https://github.com/insightsengineering/teal.modules.general/ @@ -26,7 +27,6 @@ Depends: ggplot2 (>= 3.4.0), R (>= 3.6), shiny (>= 1.6.0), - shinyTree, teal (>= 0.14.0.9027), teal.transform (>= 0.4.0.9011) Imports: @@ -36,21 +36,21 @@ Imports: forcats (>= 1.0.0), grid, logger (>= 0.2.0), - magrittr (>= 1.5), scales, shinyjs, + shinyTree, shinyvalidate, shinyWidgets (>= 0.5.1), stats, stringr (>= 1.4.1), teal.code (>= 0.4.1.9009), + teal.data (>= 0.3.0.9018), teal.logger (>= 0.1.1), teal.reporter (>= 0.2.0), teal.widgets (>= 0.4.0), tern (>= 0.7.10), tibble (>= 2.0.0), tidyr (>= 0.8.3), - tidyselect, utils Suggests: broom (>= 0.7.10), @@ -65,12 +65,10 @@ Suggests: knitr (>= 1.42), lattice (>= 0.18-4), MASS, - methods, nestcolor (>= 0.1.0), rlang (>= 1.0.0), rtables (>= 0.5.1), sparkline, - teal.data (>= 0.3.0.9018), testthat (>= 3.0.4) VignetteBuilder: knitr @@ -82,7 +80,7 @@ Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2, insightsengineering/teal.code, insightsengineering/teal.logger, insightsengineering/teal.reporter, insightsengineering/teal.transform, insightsengineering/teal.widgets, insightsengineering/tern, - tidyverse/tibble, tidyverse/tidyr, r-lib/tidyselect, tidymodels/broom, + tidyverse/tibble, tidyverse/tidyr, tidymodels/broom, daattali/colourpicker, daattali/ggExtra, aphalo/ggpmisc, aphalo/ggpp, baddstats/goftest, gridExtra, ramnathv/htmlwidgets, jeroen/jsonlite, yihui/knitr, deepayan/lattice, MASS, insightsengineering/nestcolor, diff --git a/NAMESPACE b/NAMESPACE index 28e4e2d48..86c4c2a5a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,7 +28,6 @@ export(tm_variable_browser) import(ggmosaic) import(ggplot2) import(shiny) -import(shinyTree) import(teal) import(teal.transform) -importFrom(magrittr,"%>%") +importFrom(dplyr,"%>%") diff --git a/R/teal.modules.general.R b/R/teal.modules.general.R index 74c5d52c2..a6cad3d13 100644 --- a/R/teal.modules.general.R +++ b/R/teal.modules.general.R @@ -6,10 +6,9 @@ #' @import ggplot2 #' @import ggmosaic #' @import shiny -#' @import shinyTree #' @import teal #' @import teal.transform -#' @importFrom magrittr %>% +#' @importFrom dplyr %>% #' #' #' @name teal.modules.general @@ -19,7 +18,7 @@ # nolint start # Note ggmosaic (version <= 0.3.3) needs to be in DEPENDS as the following does not work if it is imported # df <- data.frame(x = c("A", "B", "C", "A"), y = c("Z", "Z", "W", "W")) -# ggplot(df) + ggmosaic::geom_mosaic(aes(x = ggmosaic::product(x), fill = y)) +# ggplot(df) + ggmosaic::geom_mosaic(aes(x = ggmosaic::product(x), fill = y)) # nolint end # Needed to avoid R CMD note on no visible binding diff --git a/R/tm_a_pca.R b/R/tm_a_pca.R index 5fd0400b5..a21edc708 100644 --- a/R/tm_a_pca.R +++ b/R/tm_a_pca.R @@ -24,7 +24,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' USArrests <- USArrests #' }) #' datanames(data) <- "USArrests" @@ -61,7 +61,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' ADSL <- rADSL #' }) #' datanames(data) <- "ADSL" diff --git a/R/tm_a_regression.R b/R/tm_a_regression.R index fbf45f765..26f3180ba 100644 --- a/R/tm_a_regression.R +++ b/R/tm_a_regression.R @@ -35,7 +35,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' CO2 <- CO2 #' }) #' datanames(data) <- c("CO2") @@ -80,7 +80,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' ADSL <- rADSL #' }) #' datanames(data) <- "ADSL" diff --git a/R/tm_data_table.R b/R/tm_data_table.R index b8b0bcf1e..df7888227 100644 --- a/R/tm_data_table.R +++ b/R/tm_data_table.R @@ -31,7 +31,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' iris <- iris #' }) #' datanames(data) <- c("iris") @@ -54,7 +54,7 @@ #' # CDISC data example #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' ADSL <- rADSL #' }) #' datanames(data) <- "ADSL" @@ -301,7 +301,7 @@ srv_data_table <- function(id, teal::validate_has_data(df, min_nrow = 1L, msg = paste("data", dataname, "is empty")) dataframe_selected <- if (if_distinct()) { - dplyr::count(df, dplyr::across(tidyselect::all_of(variables))) + dplyr::count(df, dplyr::across(dplyr::all_of(variables))) } else { df[variables] } diff --git a/R/tm_front_page.R b/R/tm_front_page.R index aa755d64f..e2d7def39 100644 --- a/R/tm_front_page.R +++ b/R/tm_front_page.R @@ -19,7 +19,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' ADSL <- teal.modules.general::rADSL #' attr(ADSL, "metadata") <- list("Author" = "NEST team", "data_source" = "synthetic data") #' }) diff --git a/R/tm_g_association.R b/R/tm_g_association.R index 9004fe84f..e262cb584 100644 --- a/R/tm_g_association.R +++ b/R/tm_g_association.R @@ -24,7 +24,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' CO2 <- CO2 #' factors <- names(Filter(isTRUE, vapply(CO2, is.factor, logical(1L)))) #' CO2[factors] <- lapply(CO2[factors], as.character) @@ -69,7 +69,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' ADSL <- rADSL #' }) #' datanames(data) <- "ADSL" diff --git a/R/tm_g_bivariate.R b/R/tm_g_bivariate.R index ed49dd21e..fc82181c5 100644 --- a/R/tm_g_bivariate.R +++ b/R/tm_g_bivariate.R @@ -49,7 +49,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' CO2 <- data.frame(CO2) #' }) #' datanames(data) <- c("CO2") @@ -112,7 +112,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' ADSL <- rADSL #' }) #' datanames(data) <- c("ADSL") diff --git a/R/tm_g_response.R b/R/tm_g_response.R index 517c80edd..386e2aa17 100644 --- a/R/tm_g_response.R +++ b/R/tm_g_response.R @@ -30,7 +30,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' mtcars <- mtcars #' for (v in c("cyl", "vs", "am", "gear")) { #' mtcars[[v]] <- as.factor(mtcars[[v]]) @@ -78,7 +78,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' ADSL <- rADSL #' }) #' datanames(data) <- c("ADSL") diff --git a/R/tm_g_scatterplot.R b/R/tm_g_scatterplot.R index 62d7ccbf7..7f1f5d84d 100644 --- a/R/tm_g_scatterplot.R +++ b/R/tm_g_scatterplot.R @@ -39,7 +39,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' CO2 <- CO2 #' }) #' datanames(data) <- "CO2" @@ -128,7 +128,7 @@ #' #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' ADSL <- rADSL #' }) #' datanames(data) <- c("ADSL") diff --git a/R/tm_missing_data.R b/R/tm_missing_data.R index 4d733fee0..a5060206d 100644 --- a/R/tm_missing_data.R +++ b/R/tm_missing_data.R @@ -28,7 +28,7 @@ #' # general example data #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' #' add_nas <- function(x) { #' x[sample(seq_along(x), floor(length(x) * runif(1, .05, .17)))] <- NA @@ -56,7 +56,7 @@ #' # CDISC example data #' data <- teal_data() #' data <- within(data, { -#' library(nestcolor) +#' require(nestcolor) #' ADSL <- rADSL #' ADRS <- rADRS #' }) @@ -640,7 +640,7 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par substitute( expr = summary_plot_obs <- data_frame_call[, analysis_vars] %>% dplyr::summarise_all(list(function(x) sum(is.na(x)))) %>% - tidyr::pivot_longer(tidyselect::everything(), names_to = "col", values_to = "n_na") %>% + tidyr::pivot_longer(dplyr::everything(), names_to = "col", values_to = "n_na") %>% dplyr::mutate(n_not_na = nrow(ANL) - n_na) %>% tidyr::pivot_longer(-col, names_to = "isna", values_to = "n") %>% dplyr::mutate(isna = isna == "n_na", n_pct = n / nrow(ANL) * 100), @@ -733,7 +733,7 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par summary_plot_patients <- ANL[, c(parent_keys, analysis_vars)] %>% dplyr::group_by_at(parent_keys) %>% dplyr::summarise_all(anyNA) %>% - tidyr::pivot_longer(cols = !tidyselect::all_of(parent_keys), names_to = "col", values_to = "anyna") %>% + tidyr::pivot_longer(cols = !dplyr::all_of(parent_keys), names_to = "col", values_to = "anyna") %>% dplyr::group_by_at(c("col")) %>% dplyr::summarise(count_na = sum(anyna)) %>% dplyr::mutate(count_not_na = ndistinct_subjects - count_na) %>% @@ -1041,7 +1041,7 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par summary_data <- dplyr::summarise_all(summary_data, summ_fn) %>% dplyr::mutate(group_var_name := paste0(group_var, ":", group_var_name, "(N=", count_data$n, ")")) %>% - tidyr::pivot_longer(!tidyselect::all_of(group_var), names_to = "Variable", values_to = "out") %>% + tidyr::pivot_longer(!dplyr::all_of(group_var), names_to = "Variable", values_to = "out") %>% tidyr::pivot_wider(names_from = group_var, values_from = "out") %>% dplyr::mutate(`Variable label` = create_cols_labels(Variable, just_label = TRUE), .after = Variable) }, @@ -1056,7 +1056,7 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par substitute( expr = summary_data <- ANL %>% dplyr::summarise_all(summ_fn) %>% - tidyr::pivot_longer(tidyselect::everything(), + tidyr::pivot_longer(dplyr::everything(), names_to = "Variable", values_to = paste0("Missing (N=", nrow(ANL), ")") ) %>% @@ -1119,7 +1119,7 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par # order subjects by decreasing number of missing and then by # missingness pattern (defined using sha1) order_subjects <- summary_plot_patients %>% - dplyr::select(-"id", -tidyselect::all_of(parent_keys)) %>% + dplyr::select(-"id", -dplyr::all_of(parent_keys)) %>% dplyr::transmute( id = dplyr::row_number(), number_NA = apply(., 1, sum), @@ -1130,7 +1130,7 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par # order columns by decreasing percent of missing values ordered_columns <- summary_plot_patients %>% - dplyr::select(-"id", -tidyselect::all_of(parent_keys)) %>% + dplyr::select(-"id", -dplyr::all_of(parent_keys)) %>% dplyr::summarise( column = create_cols_labels(colnames(.)), na_count = apply(., MARGIN = 2, FUN = sum), @@ -1139,7 +1139,7 @@ srv_missing_data <- function(id, data, reporter, filter_panel_api, dataname, par dplyr::arrange(na_percent, dplyr::desc(column)) summary_plot_patients <- summary_plot_patients %>% - tidyr::gather("col", "isna", -"id", -tidyselect::all_of(parent_keys)) %>% + tidyr::gather("col", "isna", -"id", -dplyr::all_of(parent_keys)) %>% dplyr::mutate(col = create_cols_labels(col)) }) ) %>% diff --git a/man/tm_a_pca.Rd b/man/tm_a_pca.Rd index 0242a7910..c152ab5fe 100644 --- a/man/tm_a_pca.Rd +++ b/man/tm_a_pca.Rd @@ -72,7 +72,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) USArrests <- USArrests }) datanames(data) <- "USArrests" @@ -109,7 +109,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) ADSL <- rADSL }) datanames(data) <- "ADSL" diff --git a/man/tm_a_regression.Rd b/man/tm_a_regression.Rd index 8777542a4..053246eea 100644 --- a/man/tm_a_regression.Rd +++ b/man/tm_a_regression.Rd @@ -86,7 +86,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) CO2 <- CO2 }) datanames(data) <- c("CO2") @@ -131,7 +131,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) ADSL <- rADSL }) datanames(data) <- "ADSL" diff --git a/man/tm_data_table.Rd b/man/tm_data_table.Rd index 064aaaa8b..8cbdde1f0 100644 --- a/man/tm_data_table.Rd +++ b/man/tm_data_table.Rd @@ -60,7 +60,7 @@ Note though that sorting of numeric columns with \code{NA}/\code{Inf} will be le data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) iris <- iris }) datanames(data) <- c("iris") @@ -83,7 +83,7 @@ if (interactive()) { # CDISC data example data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) ADSL <- rADSL }) datanames(data) <- "ADSL" diff --git a/man/tm_front_page.Rd b/man/tm_front_page.Rd index 0efa390d0..20499592a 100644 --- a/man/tm_front_page.Rd +++ b/man/tm_front_page.Rd @@ -42,7 +42,7 @@ This \code{teal} module creates a simple front page for \code{teal} applications data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) ADSL <- teal.modules.general::rADSL attr(ADSL, "metadata") <- list("Author" = "NEST team", "data_source" = "synthetic data") }) diff --git a/man/tm_g_association.Rd b/man/tm_g_association.Rd index d5182e335..1bfeb9c64 100644 --- a/man/tm_g_association.Rd +++ b/man/tm_g_association.Rd @@ -69,7 +69,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) CO2 <- CO2 factors <- names(Filter(isTRUE, vapply(CO2, is.factor, logical(1L)))) CO2[factors] <- lapply(CO2[factors], as.character) @@ -114,7 +114,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) ADSL <- rADSL }) datanames(data) <- "ADSL" diff --git a/man/tm_g_bivariate.Rd b/man/tm_g_bivariate.Rd index f1d0398d6..6ebecdd90 100644 --- a/man/tm_g_bivariate.Rd +++ b/man/tm_g_bivariate.Rd @@ -114,7 +114,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) CO2 <- data.frame(CO2) }) datanames(data) <- c("CO2") @@ -177,7 +177,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) ADSL <- rADSL }) datanames(data) <- c("ADSL") diff --git a/man/tm_g_response.Rd b/man/tm_g_response.Rd index 71d994bb6..cab67f975 100644 --- a/man/tm_g_response.Rd +++ b/man/tm_g_response.Rd @@ -86,7 +86,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) mtcars <- mtcars for (v in c("cyl", "vs", "am", "gear")) { mtcars[[v]] <- as.factor(mtcars[[v]]) @@ -134,7 +134,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) ADSL <- rADSL }) datanames(data) <- c("ADSL") diff --git a/man/tm_g_scatterplot.Rd b/man/tm_g_scatterplot.Rd index 16d14c6b0..54e0dfd79 100644 --- a/man/tm_g_scatterplot.Rd +++ b/man/tm_g_scatterplot.Rd @@ -100,7 +100,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) CO2 <- CO2 }) datanames(data) <- "CO2" @@ -189,7 +189,7 @@ library(teal.widgets) data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) ADSL <- rADSL }) datanames(data) <- c("ADSL") diff --git a/man/tm_missing_data.Rd b/man/tm_missing_data.Rd index 9460399f5..08c9090f9 100644 --- a/man/tm_missing_data.Rd +++ b/man/tm_missing_data.Rd @@ -66,7 +66,7 @@ tm_missing_data_module <- tm_missing_data( # general example data data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) add_nas <- function(x) { x[sample(seq_along(x), floor(length(x) * runif(1, .05, .17)))] <- NA @@ -94,7 +94,7 @@ if (interactive()) { # CDISC example data data <- teal_data() data <- within(data, { - library(nestcolor) + require(nestcolor) ADSL <- rADSL ADRS <- rADRS })