From 7967a517931e054a2c4e5de4902d475829ff2fd8 Mon Sep 17 00:00:00 2001 From: Adrian Chan Date: Wed, 11 Sep 2024 18:02:26 +0000 Subject: [PATCH] updates for deprecated function --- R/{split.R => deprec-split.R} | 11 ++++++++--- man/xportr_split.Rd | 9 +++++---- tests/testthat/test-deprecation.R | 13 +++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) rename R/{split.R => deprec-split.R} (87%) diff --git a/R/split.R b/R/deprec-split.R similarity index 87% rename from R/split.R rename to R/deprec-split.R index a0fab294..ed140f8d 100644 --- a/R/split.R +++ b/R/deprec-split.R @@ -1,4 +1,7 @@ -#' Split xpt file output +#' Deprecated - Split xpt file output +#' +#' @description +#' `r lifecycle::badge("deprecated")` #' #' Per the FDA Study Data Technical Conformance #' Guide(https://www.fda.gov/media/88173/download) section 3.3.2, dataset files @@ -18,8 +21,8 @@ #' knows how to split the data frame. #' #' -#' @export #' +#' @export #' @examples #' #' adlb <- data.frame( @@ -29,7 +32,9 @@ #' #' adlb <- xportr_split(adlb, "LBCAT") xportr_split <- function(.df, split_by = NULL) { + .Deprecated("xportr_write(max_size_gb = ..") attr(.df, "_xportr.split_by_") <- split_by - return(.df) } + +#' @rdname xportr_split-deprecated diff --git a/man/xportr_split.Rd b/man/xportr_split.Rd index 34223a5f..79d76f1d 100644 --- a/man/xportr_split.Rd +++ b/man/xportr_split.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/split.R +% Please edit documentation in R/deprec-split.R \name{xportr_split} \alias{xportr_split} -\title{Split xpt file output} +\title{Deprecated - Split xpt file output} \usage{ xportr_split(.df, split_by = NULL) } @@ -16,13 +16,14 @@ A data frame with an additional attribute added so \code{xportr_write()} knows how to split the data frame. } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + Per the FDA Study Data Technical Conformance Guide(https://www.fda.gov/media/88173/download) section 3.3.2, dataset files sizes shouldn't exceed 5 GB. If datasets are large enough, they should be split based on a variable. For example, laboratory readings in \code{ADLB} can be split by \code{LBCAT} to split up hematology and chemistry data. -} -\details{ + This function will tell \code{xportr_write()} to split the data frame based on the variable passed in \code{split_by}. When written, the file name will be prepended with a number for uniqueness. These files should be noted in the Reviewer Guides per diff --git a/tests/testthat/test-deprecation.R b/tests/testthat/test-deprecation.R index 23d7c55a..59d49ff7 100644 --- a/tests/testthat/test-deprecation.R +++ b/tests/testthat/test-deprecation.R @@ -98,3 +98,16 @@ test_that( expect_error(xportr_type(df, metacore = df_meta)) } ) + +## Test 7: xportr_split: using deprecated function gives a warning---- +test_that( + "deprecation xportr_split: using deprecated function gives a warning", + { + adlb <- data.frame( + USUBJID = c(1001, 1002, 1003), + LBCAT = c("HEMATOLOGY", "HEMATOLOGY", "CHEMISTRY") + ) + + expect_warning(adlb <- xportr_split(adlb, "LBCAT")) + } +)