diff --git a/DESCRIPTION b/DESCRIPTION index 8ee91ef0..40d33df3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,6 +42,7 @@ Suggests: knitr, labelled, metacore, + pharmaverseadam, readxl, rmarkdown, testthat (>= 3.0.0), diff --git a/NEWS.md b/NEWS.md index e740f595..b82cf657 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # xportr 0.4.0 +## xportr development version + +* New argument in `xportr_write()` allows users to specify the maximum file size (in gb) of their exported xpt files. (#268) + ## New Features * All core functions can be run together by using new function `xportr()` (#137) diff --git a/R/write.R b/R/write.R index b714f356..c8cebd25 100644 --- a/R/write.R +++ b/R/write.R @@ -183,7 +183,7 @@ export_to_xpt <- function(.df, path, max_size_gb, file_prefix) { high <- mid - 1 } - unlink(temp_file) # Clean up the temporary file + unlink(temp_file) # Clean up the temporary file } # Write the best fitting chunk to the final file diff --git a/man/xportr_write.Rd b/man/xportr_write.Rd index f19e57be..0bb85700 100644 --- a/man/xportr_write.Rd +++ b/man/xportr_write.Rd @@ -7,6 +7,7 @@ xportr_write( .df, path, + max_size_gb = NULL, metadata = NULL, domain = NULL, strict_checks = FALSE, @@ -19,6 +20,8 @@ xportr_write( \item{path}{Path where transport file will be written. File name sans will be used as \code{xpt} name.} +\item{max_size_gb}{Maximum size in gb of the exported files} + \item{metadata}{A data frame containing dataset. See 'Metadata' section for details.} diff --git a/tests/testthat/test-write.R b/tests/testthat/test-write.R index 7be6c043..54835bc5 100644 --- a/tests/testthat/test-write.R +++ b/tests/testthat/test-write.R @@ -214,19 +214,19 @@ test_that("write Test 13: Capture errors by haven and report them as such", { ## Test 14: xportr_write: `max_size_gb` is used to split data frame into specified maximum file size ---- test_that("write Test 14: `max_size_gb` is used to split data frame into specified maximum file size", { -adlb <- pharmaverseadam::adlb + adlb <- pharmaverseadam::adlb -tmpdir <- tempdir() + tmpdir <- tempdir() -#20 mb -max_size_gb <- 20 / 1000 + # 20 mb + max_size_gb <- 20 / 1000 -xportr_write(adlb, - path = paste0(tmpdir, "/adlb.xpt"), - domain = "adlb", - max_size_gb = max_size_gb, - strict_checks = FALSE -) + xportr_write(adlb, + path = paste0(tmpdir, "/adlb.xpt"), + domain = "adlb", + max_size_gb = max_size_gb, + strict_checks = FALSE + ) expect_true( file.exists(file.path(tmpdir, "adlb1.xpt")),