From 1f70c8a381514439305c17859790646cf0fb570e Mon Sep 17 00:00:00 2001 From: COPELLI Lorenzo Date: Wed, 22 Apr 2026 11:49:36 +0200 Subject: [PATCH] Fixed issues for CRAN submission. --- DESCRIPTION | 5 ++--- R/SCD2.R | 16 ++++++++++++++-- R/SSCD2.R | 16 ++++++++++++++-- R/activate.R | 3 --- R/deactivate.R | 3 --- R/dropEmpty.R | 12 +++++++----- R/enrich.R | 4 ++-- R/removeReplicatedColumns.R | 11 ++++++----- man/EFSATools-package.Rd | 2 +- man/SCD2.Rd | 17 ++++++++++++++--- man/SSCD2.Rd | 17 ++++++++++++++--- man/dropEmpty.Rd | 13 +++++++------ man/enrich.Rd | 5 ++--- man/removeReplicatedColumns.Rd | 12 ++++++------ 14 files changed, 89 insertions(+), 47 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 87b77f9..3739c9f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,9 +13,8 @@ Authors@R: role = c("aut", "cre"), email = "luca.belmonte@efsa.europa.eu", comment = c(ORCID = "0000-0002-7977-9170"))) -Description: Brings together all the functions developed for EFSA's ad hoc data - collections, providing tools for dataset operations as well as utilities - designed to preserve data history. +Description: Provides tools for dataset operations as well as utilities + designed to preserve data history within EFSA's ad hoc data collections. License: EUPL-1.2 URL: https://openefsa.github.io/EFSATools/ BugReports: https://github.com/openefsa/EFSATools/issues diff --git a/R/SCD2.R b/R/SCD2.R index 0f53f74..ee40029 100644 --- a/R/SCD2.R +++ b/R/SCD2.R @@ -28,8 +28,20 @@ #' 4. Gets the current active records that are not present in the new data #' (i.e., the records to deactivate) and deactivates them. #' -#' @examplesIf FALSE -#' mergedData <- SCD2(newData = iris, currentData = iris) +#' @examples +#' currentData_ <- tibble::tribble( +#' ~id, ~colA, ~colB, ~colC, ~IS_ACTIVE, ~START_DATE, ~END_DATE, +#' 1, "a1", "b1", "c1", TRUE, Sys.time(), as.Date(NA), +#' 2, "a2", "b2", "c2", TRUE, Sys.time(), as.Date(NA), +#' 3, "a3", "b3", "c3", TRUE, Sys.time(), as.Date(NA)) +#' +#' newData_ <- tibble::tribble( +#' ~id, ~colA, ~colB, ~colC, +#' 1, "a1", "b1", "c1", +#' 2, "a2", "b2", "c20", +#' 3, "a4", "b4", "c4") +#' +#' mergedData <- SCD2(newData = newData_, currentData = currentData_) #' #' @export #' diff --git a/R/SSCD2.R b/R/SSCD2.R index 6c6887f..93e3e9a 100644 --- a/R/SSCD2.R +++ b/R/SSCD2.R @@ -18,8 +18,20 @@ #' @importFrom checkmate assert_data_frame #' @importFrom dplyr bind_rows #' -#' @examplesIf FALSE -#' mergedData <- SSCD2(newData = iris, currentData = iris) +#' @examples +#' currentData_ <- tibble::tribble( +#' ~id, ~colA, ~colB, ~colC, ~IS_ACTIVE, ~START_DATE, ~END_DATE, +#' 1, "a1", "b1", "c1", TRUE, Sys.time(), as.Date(NA), +#' 2, "a2", "b2", "c2", TRUE, Sys.time(), as.Date(NA), +#' 3, "a3", "b3", "c3", TRUE, Sys.time(), as.Date(NA)) +#' +#' newData_ <- tibble::tribble( +#' ~id, ~colA, ~colB, ~colC, +#' 1, "a1", "b1", "c1", +#' 2, "a2", "b2", "c20", +#' 3, "a4", "b4", "c4") +#' +#' mergedData <- SSCD2(newData = newData_, currentData = currentData_) #' #' @export #' diff --git a/R/activate.R b/R/activate.R index 6a4e84e..334f884 100644 --- a/R/activate.R +++ b/R/activate.R @@ -11,9 +11,6 @@ #' @importFrom checkmate assert_data_frame #' @importFrom dplyr mutate #' -#' @examplesIf FALSE -#' activatedDataframe <- .activate(dataframe = dataframe) -#' #' @keywords internal #' @noRd #' diff --git a/R/deactivate.R b/R/deactivate.R index fc4051c..ee5ec82 100644 --- a/R/deactivate.R +++ b/R/deactivate.R @@ -11,9 +11,6 @@ #' @importFrom checkmate assert_data_frame #' @importFrom dplyr mutate #' -#' @examplesIf FALSE -#' deactivatedDataframe <- .deactivate(dataframe = dataframe) -#' #' @keywords internal #' @noRd #' diff --git a/R/dropEmpty.R b/R/dropEmpty.R index 29ffc4d..78f3144 100644 --- a/R/dropEmpty.R +++ b/R/dropEmpty.R @@ -12,14 +12,16 @@ #' @importFrom checkmate assert_data_frame #' @importFrom dplyr filter select where mutate_all #' -#' @examplesIf FALSE +#' @examples #' # The first row is going to be dropped. -#' iris[1, ] <- NA -#' iris <- dropEmpty(iris) +#' irisTest_ <- iris +#' irisTest_[1, ] <- NA +#' irisTestDropped <- dropEmpty(irisTest_) #' #' # The Species column is going to be dropped. -#' iris$Species <- NA -#' iris <- dropEmpty(iris) +#' irisTest_ <- iris +#' irisTest_$Test <- NA +#' irisTestDropped <- dropEmpty(irisTest_) #' #' @export #' diff --git a/R/enrich.R b/R/enrich.R index b1cde48..d849a1e 100644 --- a/R/enrich.R +++ b/R/enrich.R @@ -20,12 +20,12 @@ #' @importFrom dplyr select mutate left_join #' @importFrom rlang .data := #' -#' @examplesIf FALSE +#' @examples #' dataframe_ <- iris |> dplyr::rename(CODE = Species) #' #' catalogue_ <- iris |> #' dplyr::rename(CODE = Species) |> -#' dplyr::mutate(NAME = "data") |> +#' dplyr::mutate(NAME = "test") |> #' dplyr::select(CODE, NAME) |> #' unique() #' diff --git a/R/removeReplicatedColumns.R b/R/removeReplicatedColumns.R index 4aba464..57d1f87 100644 --- a/R/removeReplicatedColumns.R +++ b/R/removeReplicatedColumns.R @@ -28,13 +28,14 @@ #' replaced with NAs. Finally, the new column is bound with the other columns of #' the initial dataframe. #' -#' @examplesIf FALSE -#' iris$Species_1 <- iris$Species -#' iris$Species_2 <- iris$Species -#' iris$Species <- NULL +#' @examples +#' irisTest_ <- iris +#' irisTest_$Species_1 <- irisTest_$Species +#' irisTest_$Species_2 <- irisTest_$Species +#' irisTest_$Species <- NULL #' #' deduplicatedDataframe_ <- removeReplicatedColumns( -#' dataframe = iris, +#' dataframe = irisTest_, #' prefix = "Species_") #' #' @export diff --git a/man/EFSATools-package.Rd b/man/EFSATools-package.Rd index cef83a2..30f4937 100644 --- a/man/EFSATools-package.Rd +++ b/man/EFSATools-package.Rd @@ -8,7 +8,7 @@ \description{ \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} -Brings together all the functions developed for EFSA's ad hoc data collections, providing tools for dataset operations as well as utilities designed to preserve data history. +Provides tools for dataset operations as well as utilities designed to preserve data history within EFSA's ad hoc data collections. } \seealso{ Useful links: diff --git a/man/SCD2.Rd b/man/SCD2.Rd index cf67afe..a05cea1 100644 --- a/man/SCD2.Rd +++ b/man/SCD2.Rd @@ -37,7 +37,18 @@ current data (i.e., the records to activate) and activates them. } } \examples{ -\dontshow{if (FALSE) withAutoprint(\{ # examplesIf} -mergedData <- SCD2(newData = iris, currentData = iris) -\dontshow{\}) # examplesIf} +currentData_ <- tibble::tribble( + ~id, ~colA, ~colB, ~colC, ~IS_ACTIVE, ~START_DATE, ~END_DATE, + 1, "a1", "b1", "c1", TRUE, Sys.time(), as.Date(NA), + 2, "a2", "b2", "c2", TRUE, Sys.time(), as.Date(NA), + 3, "a3", "b3", "c3", TRUE, Sys.time(), as.Date(NA)) + +newData_ <- tibble::tribble( + ~id, ~colA, ~colB, ~colC, + 1, "a1", "b1", "c1", + 2, "a2", "b2", "c20", + 3, "a4", "b4", "c4") + +mergedData <- SCD2(newData = newData_, currentData = currentData_) + } diff --git a/man/SSCD2.Rd b/man/SSCD2.Rd index dea4a39..e0652a2 100644 --- a/man/SSCD2.Rd +++ b/man/SSCD2.Rd @@ -25,7 +25,18 @@ all the old records and activating the new ones, even if some of the old records are still active. } \examples{ -\dontshow{if (FALSE) withAutoprint(\{ # examplesIf} -mergedData <- SSCD2(newData = iris, currentData = iris) -\dontshow{\}) # examplesIf} +currentData_ <- tibble::tribble( + ~id, ~colA, ~colB, ~colC, ~IS_ACTIVE, ~START_DATE, ~END_DATE, + 1, "a1", "b1", "c1", TRUE, Sys.time(), as.Date(NA), + 2, "a2", "b2", "c2", TRUE, Sys.time(), as.Date(NA), + 3, "a3", "b3", "c3", TRUE, Sys.time(), as.Date(NA)) + +newData_ <- tibble::tribble( + ~id, ~colA, ~colB, ~colC, + 1, "a1", "b1", "c1", + 2, "a2", "b2", "c20", + 3, "a4", "b4", "c4") + +mergedData <- SSCD2(newData = newData_, currentData = currentData_) + } diff --git a/man/dropEmpty.Rd b/man/dropEmpty.Rd index 7160bde..dce9f33 100644 --- a/man/dropEmpty.Rd +++ b/man/dropEmpty.Rd @@ -19,13 +19,14 @@ This function drops all the empty lines and columns from the specified data frame, i.e. all the rows and columns that contain only NAs. } \examples{ -\dontshow{if (FALSE) withAutoprint(\{ # examplesIf} # The first row is going to be dropped. -iris[1, ] <- NA -iris <- dropEmpty(iris) +irisTest_ <- iris +irisTest_[1, ] <- NA +irisTestDropped <- dropEmpty(irisTest_) # The Species column is going to be dropped. -iris$Species <- NA -iris <- dropEmpty(iris) -\dontshow{\}) # examplesIf} +irisTest_ <- iris +irisTest_$Test <- NA +irisTestDropped <- dropEmpty(irisTest_) + } diff --git a/man/enrich.Rd b/man/enrich.Rd index ef02c2a..bac1464 100644 --- a/man/enrich.Rd +++ b/man/enrich.Rd @@ -26,12 +26,11 @@ This function takes a data frame and joins it with an EFSA catalog. The EFSA catalog must be itself a data frame. } \examples{ -\dontshow{if (FALSE) withAutoprint(\{ # examplesIf} dataframe_ <- iris |> dplyr::rename(CODE = Species) catalogue_ <- iris |> dplyr::rename(CODE = Species) |> - dplyr::mutate(NAME = "data") |> + dplyr::mutate(NAME = "test") |> dplyr::select(CODE, NAME) |> unique() @@ -40,5 +39,5 @@ enriched_ <- enrich( catalogue = catalogue_, joinBy = "CODE", enrichedColumnName = "enrichedColumn") -\dontshow{\}) # examplesIf} + } diff --git a/man/removeReplicatedColumns.Rd b/man/removeReplicatedColumns.Rd index 75b169b..2d1909b 100644 --- a/man/removeReplicatedColumns.Rd +++ b/man/removeReplicatedColumns.Rd @@ -31,13 +31,13 @@ replaced with NAs. Finally, the new column is bound with the other columns of the initial dataframe. } \examples{ -\dontshow{if (FALSE) withAutoprint(\{ # examplesIf} -iris$Species_1 <- iris$Species -iris$Species_2 <- iris$Species -iris$Species <- NULL +irisTest_ <- iris +irisTest_$Species_1 <- irisTest_$Species +irisTest_$Species_2 <- irisTest_$Species +irisTest_$Species <- NULL deduplicatedDataframe_ <- removeReplicatedColumns( - dataframe = iris, + dataframe = irisTest_, prefix = "Species_") -\dontshow{\}) # examplesIf} + }