diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 562fe0f..6435ce8 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -21,6 +21,7 @@ jobs: config: - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} + - {os: windows-latest, r: 'oldrel-1'} - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - {os: ubuntu-latest, r: 'release'} - {os: ubuntu-latest, r: 'oldrel-1'} diff --git a/DESCRIPTION b/DESCRIPTION index 9131b8b..f2725e4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,15 +1,15 @@ Package: repfun -Title: Create TLFs using Functions Styled after SAS™ Macros +Title: Create Tables, Listings and Figures using Functions Styled after SAS™ Macros Version: 0.1.0 Authors@R: c(person("Chris", "Rook", , "cr883296@gmail.com", role = c("aut", "cre")), person("Yongwei", "Wang", , "yongwei.x.wang@viivhealthcare.com", role = c("aut")), person("GlaxoSmithKline Research & Development Limited", role = c("cph", "fnd"))) -Description: Mimic the style of traditional reporting macros for clinical trials. The purpose is to generate TLFs (tables, listings and figures) that support clinical research. - This package is well suited for firms or individuals who wish to incorporate R without changing their - ways of working as it follows a traditional clinical research workflow. Invoke functions (instead of macros) to - summarize data and produce formatted reports. This package differs from others in that it includes - tools (wrappers) for both analyzing and reporting data. +Description: Mimic the style of traditional reporting macros for clinical trials. The purpose is to generate tables, listings + and figures that support clinical research. This package is well suited for firms or individuals who wish to + incorporate R without changing their ways of working as it follows a traditional clinical research workflow. + Invoke functions (instead of macros) to summarize data and produce formatted reports. This package differs from + others in that it includes tools (wrappers) for both analyzing and reporting data. License: Apache License (== 2.0) Encoding: UTF-8 Roxygen: list(markdown = TRUE) diff --git a/NAMESPACE b/NAMESPACE index fdabb58..bc07d5d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,7 +27,6 @@ export(ru_setdata) export(ru_stackvar) export(ru_sumstats) export(ru_width_rtf) -export(setpath) import(dplyr) import(haven) import(r2rtf) diff --git a/R/ru_list.R b/R/ru_list.R index a609dbc..9ad32a6 100644 --- a/R/ru_list.R +++ b/R/ru_list.R @@ -37,8 +37,8 @@ #' @param flowvars Variables with flow option #' @param widths Column widths #' @param defaultwidths List of default column widths -#' @param skipvars similar to SAS statement skipvars Break after / skip -#' @param pagevars similar to SAS statement pagevars Break after / page +#' @param skipvars similar to SAS statement skipvars Break after skip +#' @param pagevars similar to SAS statement pagevars Break after page #' @param idvars ID variables #' @param linevars Order variable printed with line statements. #' @param centrevars Centre justify variables diff --git a/R/setpath.R b/R/setpath.R deleted file mode 100644 index 30bc1c3..0000000 --- a/R/setpath.R +++ /dev/null @@ -1,32 +0,0 @@ -#' Set the current working directory. -#' -#' Set the current working directory so that relative paths work as expected. -#' -#' @param p A path as a string. -#' -#' @return 'NULL' because the current working directory is set. -#' -#' @author Yongwei Wang, \email{yongwei.x.wang@viivhealthcare.com} \cr -#' Chris Rook, \email{cr883296@gmail.com} -#' -#' @examples -#'\dontrun{ -#' library(repfun) -#' repfun::setpath() -#'} -#' @export -#' -setpath <- function(p){ -tryCatch( - expr = {setwd(p)}, - error = function(e){tryCatch(expr = {setwd(rprojroot::find_root(rprojroot::is_rstudio_project))}, - error = function(e){tryCatch(expr = {setwd(rfenv$PATH)}, - error = { - message('Current Working Directory: ', getwd()) - message('The Current Working Directory Has Not Been Set As Expected (An Issue). It Must Be Set By The User.')})})}, - finally = { - #message(paste0('Current Working Directory is: ',getwd())) - } -) - return(invisible(NULL)) -} diff --git a/README.md b/README.md index a5fe32e..9c8691d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ## R Reporting Functions Repository -This repository contains an R package of reporting functions that mimic (HARP) traditional macros for clinical reporting. The package can be used to generate TLFs (Tables, Listings, Figures). See several examples in the Vignettes/Articles. +This repository contains an R package of reporting functions that mimic (HARP) traditional macros for clinical reporting. The package can be used to generate Tables, Listings and Figures. See several examples in the Vignettes/Articles.

(back to top)

@@ -72,7 +72,7 @@ install.packages(c("tidyr","dplyr","ggplot2","magrittr","Hmisc","haven","stringr ## License -This project is released under the Apache-2.0 license. See the **[LICENSE](LICENSE.md)** file for details. +This project is released under the Apache-2.0 license.

(back to top)

diff --git a/_pkgdown.yml b/_pkgdown.yml index 9d603dd..ed508d1 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -68,7 +68,6 @@ reference: - ru_setdata - ru_stackvar - ru_width_rtf - - setpath - rem_pg_nums - copydata - title: Data diff --git a/man/repfun-package.Rd b/man/repfun-package.Rd index 52908e0..382bf6b 100644 --- a/man/repfun-package.Rd +++ b/man/repfun-package.Rd @@ -4,9 +4,9 @@ \name{repfun-package} \alias{repfun} \alias{repfun-package} -\title{repfun: Create TLFs using Functions Styled after SAS™ Macros} +\title{repfun: Create Tables, Listings and Figures using Functions Styled after SAS™ Macros} \description{ -Mimic the style of traditional reporting macros for clinical trials. The purpose is to generate TLFs (tables, listings and figures) that support clinical research. This package is well suited for firms or individuals who wish to incorporate R without changing their ways of working as it follows a traditional clinical research workflow. Invoke functions (instead of macros) to summarize data and produce formatted reports. This package differs from others in that it includes tools (wrappers) for both analyzing and reporting data. +Mimic the style of traditional reporting macros for clinical trials. The purpose is to generate tables, listings and figures that support clinical research. This package is well suited for firms or individuals who wish to incorporate R without changing their ways of working as it follows a traditional clinical research workflow. Invoke functions (instead of macros) to summarize data and produce formatted reports. This package differs from others in that it includes tools (wrappers) for both analyzing and reporting data. } \seealso{ Useful links: diff --git a/man/ru_list.Rd b/man/ru_list.Rd index d842b83..2774472 100644 --- a/man/ru_list.Rd +++ b/man/ru_list.Rd @@ -154,9 +154,9 @@ ru_list( \item{defaultwidths}{List of default column widths} -\item{skipvars}{similar to SAS statement skipvars Break after \if{html}{\out{}} / skip} +\item{skipvars}{similar to SAS statement skipvars Break after skip} -\item{pagevars}{similar to SAS statement pagevars Break after \if{html}{\out{}} / page} +\item{pagevars}{similar to SAS statement pagevars Break after page} \item{idvars}{ID variables} diff --git a/man/setpath.Rd b/man/setpath.Rd deleted file mode 100644 index 0e5083c..0000000 --- a/man/setpath.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/setpath.R -\name{setpath} -\alias{setpath} -\title{Set the current working directory.} -\usage{ -setpath(p) -} -\arguments{ -\item{p}{A path as a string.} -} -\value{ -'NULL' because the current working directory is set. -} -\description{ -Set the current working directory so that relative paths work as expected. -} -\examples{ -\dontrun{ -library(repfun) -repfun::setpath() -} -} -\author{ -Yongwei Wang, \email{yongwei.x.wang@viivhealthcare.com} \cr -Chris Rook, \email{cr883296@gmail.com} -} diff --git a/tests/testthat/test-rs_setup.R b/tests/testthat/test-rs_setup.R index 7312e3d..2e7aff3 100644 --- a/tests/testthat/test-rs_setup.R +++ b/tests/testthat/test-rs_setup.R @@ -5,17 +5,6 @@ test_that("environment setup works", { suppressMessages(library(tibble)) suppressMessages(library(testthat)) - #globs <- paste0(tempdir(),'/GLOBALS2.txt') - #write(getwd(),file=globs,append=TRUE) - #write(testthat::test_path(),file=globs,append=TRUE) - #write(paste0(getwd(),'/',testthat::test_path()),file=globs,append=TRUE) - #Sys.sleep(300) - - #repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #print(getwd()) - #Sys.sleep(20) - #====================== # Invoke setup macro. #====================== @@ -51,13 +40,9 @@ test_that("environment setup works", { D_DEBUG=0) ) - #print(getwd()) - #print(adamdata) - #========================================================= # Read ADSL directly, subset and compare with G_POPDATA. #========================================================= - #indata <- adamdata$adsl.rda() indata <- do.call(rfenv$adamdata$adsl.rda,list()) indata <- tibble::as_tibble(indata) indata %>% dplyr::filter(SAFFL=='Y') -> C_POPDATA diff --git a/tests/testthat/test-ru_addbignvar.R b/tests/testthat/test-ru_addbignvar.R index d1b559c..3710f17 100644 --- a/tests/testthat/test-ru_addbignvar.R +++ b/tests/testthat/test-ru_addbignvar.R @@ -5,8 +5,6 @@ test_that("adding big N works", { suppressMessages(library(testthat)) suppressMessages(library(tibble)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #======= # SETUP #======= diff --git a/tests/testthat/test-ru_addpage.R b/tests/testthat/test-ru_addpage.R index 4c73175..762b61b 100644 --- a/tests/testthat/test-ru_addpage.R +++ b/tests/testthat/test-ru_addpage.R @@ -4,8 +4,6 @@ test_that("adding page numbers works", { suppressMessages(library(dplyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #================================================== # Setup reporting environment and read in AE data. #================================================== diff --git a/tests/testthat/test-ru_addsupp.R b/tests/testthat/test-ru_addsupp.R index 0aff2c6..83116a5 100644 --- a/tests/testthat/test-ru_addsupp.R +++ b/tests/testthat/test-ru_addsupp.R @@ -5,8 +5,6 @@ test_that("combining SDTM with its supplemental data works", { suppressMessages(library(tidyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - ###### # DM # ###### diff --git a/tests/testthat/test-ru_align.R b/tests/testthat/test-ru_align.R index bf0cc08..8b2fa2f 100644 --- a/tests/testthat/test-ru_align.R +++ b/tests/testthat/test-ru_align.R @@ -5,8 +5,6 @@ test_that("aligning columns works", { suppressMessages(library(tidyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #================= # Adverse Events #================= diff --git a/tests/testthat/test-ru_contents.R b/tests/testthat/test-ru_contents.R index 3afe126..74d6d13 100644 --- a/tests/testthat/test-ru_contents.R +++ b/tests/testthat/test-ru_contents.R @@ -3,8 +3,6 @@ test_that("proc contents works", { suppressMessages(library(repfun)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #============================================= # Put contents of mtcars into temporary file. #============================================= diff --git a/tests/testthat/test-ru_data2codelist.R b/tests/testthat/test-ru_data2codelist.R index bdb36c8..a89335f 100644 --- a/tests/testthat/test-ru_data2codelist.R +++ b/tests/testthat/test-ru_data2codelist.R @@ -3,8 +3,6 @@ test_that("converting data to codelist works", { suppressMessages(library(repfun)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #============================================================================== # Build a codelist style format off of a SAS data set containing a SAS format. #============================================================================== diff --git a/tests/testthat/test-ru_datacompare.R b/tests/testthat/test-ru_datacompare.R index cfc9bf8..f35e931 100644 --- a/tests/testthat/test-ru_datacompare.R +++ b/tests/testthat/test-ru_datacompare.R @@ -4,8 +4,6 @@ test_that("proc compare works", { suppressMessages(library(dplyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - iris1 <- iris %>% dplyr::mutate(ID=dplyr::row_number()) iris2 <- iris %>% dplyr::mutate(ID=dplyr::row_number()) %>% dplyr::mutate(Petal.Length=Petal.Length+1) irisdiffs <- repfun::ru_datacompare(iris1, iris2, idvars=c('Species','ID')) diff --git a/tests/testthat/test-ru_datetime.R b/tests/testthat/test-ru_datetime.R index f49cd95..926ee7d 100644 --- a/tests/testthat/test-ru_datetime.R +++ b/tests/testthat/test-ru_datetime.R @@ -4,8 +4,6 @@ test_that("adding formatted datetimes works", { suppressMessages(library(dplyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #================================================= # Read SDTM.AE and add time values to the dates. #================================================= diff --git a/tests/testthat/test-ru_denorm.R b/tests/testthat/test-ru_denorm.R index 0d78343..4d89371 100644 --- a/tests/testthat/test-ru_denorm.R +++ b/tests/testthat/test-ru_denorm.R @@ -5,8 +5,6 @@ test_that("transposing a dataframe works", { suppressMessages(library(tidyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #====================== #====================== # Adverse Events Test diff --git a/tests/testthat/test-ru_expvarlist.R b/tests/testthat/test-ru_expvarlist.R index 0e9256b..50bd357 100644 --- a/tests/testthat/test-ru_expvarlist.R +++ b/tests/testthat/test-ru_expvarlist.R @@ -3,8 +3,6 @@ test_that("expanding variable list works", { suppressMessages(library(repfun)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #======== # Test 1 #======== diff --git a/tests/testthat/test-ru_fillcodedcode.R b/tests/testthat/test-ru_fillcodedcode.R index 5bde31a..7d95cec 100644 --- a/tests/testthat/test-ru_fillcodedcode.R +++ b/tests/testthat/test-ru_fillcodedcode.R @@ -4,9 +4,6 @@ test_that("populating a decode variable works", { suppressMessages(library(dplyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #rfenv$G_DEBUG <<- 0 - #======================================== # Create decode for SEX using function. #======================================== diff --git a/tests/testthat/test-ru_freq.R b/tests/testthat/test-ru_freq.R index 82b33f1..6caa08b 100644 --- a/tests/testthat/test-ru_freq.R +++ b/tests/testthat/test-ru_freq.R @@ -5,8 +5,6 @@ test_that("generating counts and percents works", { suppressMessages(library(tidyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #=============================== # Set up reporting environment. #=============================== diff --git a/tests/testthat/test-ru_getdata.R b/tests/testthat/test-ru_getdata.R index 78488aa..ca8c8e8 100644 --- a/tests/testthat/test-ru_getdata.R +++ b/tests/testthat/test-ru_getdata.R @@ -4,8 +4,6 @@ test_that("get data function works", { suppressMessages(library(dplyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #========================= # Set up the environment. #========================= diff --git a/tests/testthat/test-ru_groupbyvars.R b/tests/testthat/test-ru_groupbyvars.R index 7100cd3..d703f1a 100644 --- a/tests/testthat/test-ru_groupbyvars.R +++ b/tests/testthat/test-ru_groupbyvars.R @@ -3,8 +3,6 @@ test_that("multiplication works", { suppressMessages(library(repfun)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #=================================== # Add decode variables to the list. #=================================== diff --git a/tests/testthat/test-ru_libname.R b/tests/testthat/test-ru_libname.R index d0e06c2..8bea55a 100644 --- a/tests/testthat/test-ru_libname.R +++ b/tests/testthat/test-ru_libname.R @@ -4,8 +4,6 @@ test_that("ru_libname works for rds and rda files", { suppressMessages(library(dplyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #================================================== # Read ADSL RDA file, restrict to SAFETY subjects. #================================================== diff --git a/tests/testthat/test-ru_list.R b/tests/testthat/test-ru_list.R index 9d8f672..2f2f2e8 100644 --- a/tests/testthat/test-ru_list.R +++ b/tests/testthat/test-ru_list.R @@ -4,10 +4,9 @@ test_that("producing RTFs works", { suppressMessages(library(dplyr)) suppressMessages(library(tidyr)) suppressMessages(library(haven)) + suppressMessages(library(ggplot2)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #=================================== # Set up the reporting environment. #=================================== @@ -56,7 +55,7 @@ test_that("producing RTFs works", { # Prod Table 1: Summary of Adverse Events - DDDATA only. #========================================================== repfun::ru_list(aesum, - display='N', + display='Y', columns=c('AEBODSYS','AEDECOD','tt_01','tt_02','tt_03','tt_99'), nowidowvar='AEBODSYS', widths=c(5.5,4.5,1.75,1.9,1.9,1.75), @@ -107,6 +106,87 @@ test_that("producing RTFs works", { #================== testthat::expect_equal(prod1, qc1) + #========================================================== + # Prod Table 3: Summary of Adverse Events - DDDATA only. + #========================================================== + setup(3) + aesum <- repfun::ru_freq(rfenv$adamdata$adae.rda() %>% dplyr::select(-SAFFL) %>% + repfun::ru_getdata(rfenv$G_POPDATA, c("STUDYID", "USUBJID"), keeppopvars=c("TRT01AN", "TRT01A")), + dsetindenom=rfenv$G_POPDATA, + countdistinctvars=c('STUDYID','USUBJID'), + groupbyvarsnumer=c('TRT01AN','TRT01A','AEBODSYS','AEDECOD'), + anyeventvars = c('AEBODSYS','AEDECOD'), + anyeventvalues = c('ANY EVENT','ANY EVENT'), + groupbyvarsdenom=c('TRT01AN'), + resultstyle="NUMERPCT", + totalforvar=c('TRT01AN'), + totalid=99, + totaldecode='Total', + codedecodevarpairs=c("TRT01AN", "TRT01A"), + varcodelistpairs=c(""), + codelistnames=list(), + resultpctdps=0) %>% dplyr::arrange(TRT01AN,TRT01A,AEBODSYS,tt_summarylevel,AEDECOD,NUMERCNT,DENOMCNT) %>% repfun::ru_align("tt_result") + + #========= + #========= + # PROD 3 + #========= + #========= + aetbls <- list('Gender: Male'=aesum, + 'Gender: Female'=aesum) + + repfun::ru_list(aetbls, + display='Y', + columns=c('AEBODSYS','AEDECOD','tt_01','tt_02','tt_03','tt_99'), + nowidowvar='AEBODSYS', + widths=c(5.5,4.5,1.75,1.9,1.9,1.75), + skipvars=c('AEBODSYS'), + centrevars=c('tt_01','tt_02','tt_03','tt_99'), + ordervars=c('AEBODSYS','tt_summarylevel','AEDECOD'), + noprintvars=c('tt_summarylevel'), + denormyn='Y', + varsToDenorm=c('tt_result'), + groupByVars=c('AEBODSYS','tt_summarylevel','AEDECOD'), + acrossVar="TRT01AN", + acrossVarLabel="TRT01A", + acrossColVarPrefix='tt_', + dddatasetlabel=paste0('DD Dataframe for AE Table ',rfenv$G_DSPLYNUM), + lpp=23, + rpp=50) + + prod3 <- readRDS(paste0(tmpdr,'/t_ru_list_3.rds')) + prod3[] <- lapply(prod3, as.character) + attr(prod3, 'label') <- NULL + + #======= + #======= + # QC 3 + #======= + #======= + qc3 <- aesum %>% dplyr::mutate(TRT01A=paste0(TRT01A,'\\line (N=',DENOMCNT,')\\line n (%)')) %>% + repfun::ru_denorm(varstodenorm=c("tt_result", "PERCENT"), groupbyvars=c("tt_summarylevel", "AEBODSYS", "AEDECOD"), acrossvar="TRT01AN", + acrossvarlabel="TRT01A", acrossvarprefix=c("tt_", "tt_p")) %>% {lapply(., attr, "label") ->> LBLS; .} %>% dplyr::arrange(AEBODSYS,tt_summarylevel,AEDECOD) %>% + dplyr::select(-starts_with('tt_p'),-tt_summarylevel) %>% dplyr::group_by(AEBODSYS) %>% dplyr::group_modify(~ add_row(.x,.after=Inf)) %>% + dplyr::ungroup() %>% dplyr::mutate(dplyr::across(dplyr::everything(), ~ tidyr::replace_na(.x, ""))) %>% dplyr::mutate(dplyr::across(dplyr::everything(), as.character)) %>% + repfun::ru_labels(varlabels=LBLS,style='base') %>% + repfun::ru_addpage(grpvars=c('AEBODSYS'),rowsprbdy=19) + + qc3 %>% group_by(AEBODSYS) %>% mutate(lastrow=ifelse(row_number()==n(),TRUE,FALSE), + frstpage=ifelse(lastrow & !PAGEVAR==lag(PAGEVAR),TRUE,FALSE)) %>% filter(!(lastrow & frstpage)) %>% select(-c(lastrow,frstpage)) -> qc3 + + qc3 <- as.data.frame(qc3) + qc3 <- rbind(qc3 %>% mutate(PAGBYCAT='Gender: Male'),qc3 %>% mutate(PAGBYCAT='Gender: Female')) + attr(qc3$PAGEVAR, "label") <- NULL + + attr(qc3,'label') <- 'DD Dataframe for AE Table 3' + qc3[] <- lapply(qc3, as.character) + attr(qc3, 'label') <- NULL + + #================== + # Test 3: Compare. + #================== + testthat::expect_equal(prod3, qc3) + #======================================================= # Generate 2nd DD data set and compare with QC version. #======================================================= @@ -114,7 +194,7 @@ test_that("producing RTFs works", { SOCterms <- aesum %>% dplyr::distinct(AEBODSYS,AEDECOD) SOCcnts <- table(SOCterms$AEBODSYS) repfun::ru_list(aesum %>% dplyr::filter(!(AEBODSYS %in% names(SOCcnts[SOCcnts>=20]))), - display='N', + display='Y', columns=c('AEBODSYS','AEDECOD','tt_01','tt_02','tt_03','tt_99'), nowidowvar='AEBODSYS', widths=c(5.5,4.5,1.75,1.9,1.9,1.75), @@ -157,6 +237,28 @@ test_that("producing RTFs works", { #================== testthat::expect_equal(prod2, qc2) + #==================================================================================== + # Test 4: Generate figure using ru_list. Check for size and existence of rtf file. + #==================================================================================== + setup(4) + assign("G_HEIGHT", rfenv$G_HEIGHT-.16 ,envir=rfenv) + myplot1 <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point() + myplot2 <- ggplot(iris, aes(Species, Sepal.Length)) + geom_boxplot() + myplots <- list('Gender: Male'=myplot1, 'Gender: Female'=myplot2) + repfun::ru_list(dsetin=myplots, + dddatasetlabel='DD Dataframe for Figure 4') + + figfil <- paste0(tmpdr,"/t_ru_list_4.rtf") + if (file.exists(figfil)){ + fsize <- file.size(figfil)/1024 + } else { + fsize <- 0 + } + + if (fsize > 5) {fsize <- 1} + + testthat::expect_equal(1,fsize) + unlink(tmpdr, recursive = TRUE) }) diff --git a/tests/testthat/test-ru_setdata.R b/tests/testthat/test-ru_setdata.R index 98dd63b..7846ea3 100644 --- a/tests/testthat/test-ru_setdata.R +++ b/tests/testthat/test-ru_setdata.R @@ -4,8 +4,6 @@ test_that("appending data sets works", { suppressMessages(library(dplyr)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #======================================================= # Append mtcars and airquality using package function. #======================================================= diff --git a/tests/testthat/test-ru_stackvar.R b/tests/testthat/test-ru_stackvar.R index e0bc26d..76a25c4 100644 --- a/tests/testthat/test-ru_stackvar.R +++ b/tests/testthat/test-ru_stackvar.R @@ -5,12 +5,10 @@ test_that("stacking variables works", { suppressMessages(library(tibble)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #===================== # Set up environment. #===================== - rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_ADAMDATA="../../data") + rs_setup(D_POPDATA=repfun::adsl %>% dplyr::filter(SAFFL =='Y'), D_SUBJID=c("STUDYID","USUBJID"), R_ADAMDATA=".") rfenv$G_POPDATA %>% dplyr::mutate(TRT01AN=ifelse(TRT01A=='Placebo',1,ifelse(TRT01A=='Xanomeline Low Dose',2,3))) %>% repfun::ru_labels(varlabels=list('TRT01AN'='Actual Treatment for Period 01 (n)')) -> G_POPDATA adae <- tibble::as_tibble(rfenv$adamdata$adae.rda()) %>% dplyr::inner_join(G_POPDATA, by=c('STUDYID','USUBJID','SAFFL','TRT01A')) diff --git a/tests/testthat/test-ru_sumstats.R b/tests/testthat/test-ru_sumstats.R index 5dc2ed6..8443297 100644 --- a/tests/testthat/test-ru_sumstats.R +++ b/tests/testthat/test-ru_sumstats.R @@ -8,8 +8,6 @@ test_that("generating summary statistics works", { options(dplyr.summarise.inform = FALSE) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #==================== # Environment setup. #==================== diff --git a/tests/testthat/test-ru_width_rtf.R b/tests/testthat/test-ru_width_rtf.R index e4abc57..a99f68d 100644 --- a/tests/testthat/test-ru_width_rtf.R +++ b/tests/testthat/test-ru_width_rtf.R @@ -6,8 +6,6 @@ test_that("generating rtf column widths works", { suppressMessages(library(tibble)) suppressMessages(library(testthat)) - repfun::setpath(paste0(rfenv$PATH,'/tests/testthat')) - #======================================================================================================================== # Create a dataframe where labels and variable value length are identical for each column and sum to 100 across columns. #========================================================================================================================