From 3a52d513802f16091bfa3e0e79ee25654b4e6cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lie=20Siberchicot?= Date: Tue, 1 Oct 2024 17:14:22 +0200 Subject: [PATCH] Replace 'library()' with 'require()' which is (about 5 times) faster --- README.md | 2 +- inst/DRomics-shiny/global.R | 18 +++++++++--------- inst/DRomics-shiny/server.R | 2 +- inst/DRomicsInterpreter-shiny/global.R | 16 ++++++++-------- inst/DRomicsInterpreter-shiny/server.R | 2 +- tests/testthat.R | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 3adaea60..2e5c502b 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ remotes::install_github("lbbe-software/DRomics") Finally load the package in your current R session with the following R command: ```r -library(DRomics) +require("DRomics") ``` diff --git a/inst/DRomics-shiny/global.R b/inst/DRomics-shiny/global.R index bd88cd5f..34978c86 100644 --- a/inst/DRomics-shiny/global.R +++ b/inst/DRomics-shiny/global.R @@ -1,12 +1,12 @@ -library(shiny, quietly = TRUE) -library(DRomics, quietly = TRUE) -library(ggplot2, quietly = TRUE) -library(shinyjs, quietly = TRUE) -library(shinyBS, quietly = TRUE) -library(shinycssloaders, quietly = TRUE) -library(tools, quietly = TRUE) -library(svglite, quietly = TRUE) +require("shiny", quietly = TRUE) +require("DRomics", quietly = TRUE) +require("ggplot2", quietly = TRUE) +require("shinyjs", quietly = TRUE) +require("shinyBS", quietly = TRUE) +require("shinycssloaders", quietly = TRUE) +require("tools", quietly = TRUE) +require("svglite", quietly = TRUE) addResourcePath('DRomicspkg', system.file("extdata", package="DRomics")) options(shiny.maxRequestSize=30*1024^2) -text_bgdose <- "The value of doses under which doses can be replaced by 0, to be considered as the background dose for BMD calculation, is necessary only if there is no dose at zero in the data. To prevent hazardous calculation of BMDs by extrapolation, DRomics will not run without null doses in the design or specification of this background dose." \ No newline at end of file +text_bgdose <- "The value of doses under which doses can be replaced by 0, to be considered as the background dose for BMD calculation, is necessary only if there is no dose at zero in the data. To prevent hazardous calculation of BMDs by extrapolation, DRomics will not run without null doses in the design or specification of this background dose." diff --git a/inst/DRomics-shiny/server.R b/inst/DRomics-shiny/server.R index 2c3a6750..b9a6a732 100644 --- a/inst/DRomics-shiny/server.R +++ b/inst/DRomics-shiny/server.R @@ -273,7 +273,7 @@ server <- function(input, output, session) { req(input$datafile_anchoring) } - text <- c("library(DRomics)", + text <- c("require('DRomics')", "", "# Step 1", paste0("o <- ", ifelse(input$typeData == 'microarraydata', diff --git a/inst/DRomicsInterpreter-shiny/global.R b/inst/DRomicsInterpreter-shiny/global.R index 9dce83f6..bf82a8e0 100644 --- a/inst/DRomicsInterpreter-shiny/global.R +++ b/inst/DRomicsInterpreter-shiny/global.R @@ -1,11 +1,11 @@ -library(shiny, quietly = TRUE) -library(shinyjs, quietly = TRUE) -library(shinyBS, quietly = TRUE) -library(shinyWidgets, quietly = TRUE) -library(DRomics, quietly = TRUE) -library(sortable, quietly = TRUE) -library(ggplot2, quietly = TRUE) -library(plotly, quietly = TRUE) +require("shiny", quietly = TRUE) +require("shinyjs", quietly = TRUE) +require("shinyBS", quietly = TRUE) +require("shinyWidgets", quietly = TRUE) +require("DRomics", quietly = TRUE) +require("sortable", quietly = TRUE) +require("ggplot2", quietly = TRUE) +require("plotly", quietly = TRUE) addResourcePath('DRomicspkg', system.file("extdata", package="DRomics")) options(shiny.maxRequestSize=30*1024^2) diff --git a/inst/DRomicsInterpreter-shiny/server.R b/inst/DRomicsInterpreter-shiny/server.R index 69096337..2d66caaa 100644 --- a/inst/DRomicsInterpreter-shiny/server.R +++ b/inst/DRomicsInterpreter-shiny/server.R @@ -695,7 +695,7 @@ server <- function(input, output, session) { req(input$annotationData1) ##### STEP 1 ##### - text <- c("library(DRomics)", + text <- c("require('DRomics')", "", "# Step 1", "extendedres <- list()", diff --git a/tests/testthat.R b/tests/testthat.R index 6795a771..12201433 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,3 +1,3 @@ -library("testthat") -library("DRomics") +require("testthat") +require("DRomics") test_check("DRomics")