From ee8df103c4203efd2325f85d12099c7a6ce2eeba Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Mar 2024 17:24:26 +0530 Subject: [PATCH 01/14] using rtbales function for flextable. --- DESCRIPTION | 9 ++- R/utils.R | 107 +++++------------------------------- tests/testthat/test-utils.R | 36 ------------ 3 files changed, 19 insertions(+), 133 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5685c5c8..abdf0e5d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,6 +31,7 @@ Imports: lifecycle (>= 0.2.0), R6, rmarkdown (>= 2.19), + rtables (>= 0.5.1), shiny (>= 1.6.0), shinybusy, shinyWidgets (>= 0.5.1), @@ -42,7 +43,6 @@ Suggests: ggplot2 (>= 3.4.0), lattice (>= 0.18-4), png, - rtables (>= 0.5.1), testthat (>= 3.1.5), tinytex VignetteBuilder: @@ -51,11 +51,10 @@ RdMacros: lifecycle Config/Needs/verdepcheck: rstudio/bslib, mllg/checkmate, rstudio/htmltools, yihui/knitr, r-lib/lifecycle, r-lib/R6, - rstudio/rmarkdown, rstudio/shiny, dreamRs/shinybusy, - dreamRs/shinyWidgets, yaml=vubiostat/r-yaml, r-lib/zip, + rstudio/rmarkdown, insightsengineering/rtables, rstudio/shiny, + dreamRs/shinybusy, dreamRs/shinyWidgets, yaml=vubiostat/r-yaml, r-lib/zip, davidgohel/flextable, rstudio/DT, yihui/formatR, tidyverse/ggplot2, - deepayan/lattice, cran/png, insightsengineering/rtables, - r-lib/testthat, rstudio/tinytex + deepayan/lattice, cran/png, r-lib/testthat, rstudio/tinytex Config/Needs/website: insightsengineering/nesttemplate Encoding: UTF-8 Language: en-US diff --git a/R/utils.R b/R/utils.R index e187155e..e37463a2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -124,76 +124,33 @@ panel_item <- function(title, ..., collapsed = TRUE, input_id = NULL) { #' #' @keywords internal to_flextable <- function(content) { - if (inherits(content, c("rtables", "TableTree", "ElementaryTable", "listing_df"))) { + if (inherits(content, c("rtables", "TableTree", "ElementaryTable"))) { + ft <- rtables::tt_to_flextable(content) + } else if (inherits(content, "listing_df")) { mf <- rtables::matrix_form(content) nr_header <- attr(mf, "nrow_header") - non_total_coln <- c(TRUE, !grepl("All Patients", names(content))) df <- as.data.frame(mf$strings[seq(nr_header + 1, nrow(mf$strings)), , drop = FALSE]) header_df <- as.data.frame(mf$strings[seq_len(nr_header), , drop = FALSE]) - ft <- flextable::flextable(df) - ft <- flextable::delete_part(ft, part = "header") - ft <- flextable::add_header(ft, values = header_df) + ft <- rtables::df_to_tt(df) + rtables::main_title(ft) <- mf$main_title + rtables::subtitles(ft) <- mf$subtitles + rtables::main_footer(ft) <- mf$main_footer + rtables::prov_footer(ft) <- mf$prov_footer + rtables::header_section_div(ft) <- mf$header_section_div + content <- ft + ft <- rtables::tt_to_flextable(ft, total_width = c(grDevices::pdf.options()$width - 1)) - # Add titles - ft <- flextable::set_caption(ft, flextable::as_paragraph( - flextable::as_b(mf$main_title), "\n", paste(mf$subtitles, collapse = "\n") - ), - align_with_table = FALSE - ) - - merge_index_body <- get_merge_index(mf$spans[seq(nr_header + 1, nrow(mf$spans)), , drop = FALSE]) - merge_index_header <- get_merge_index(mf$spans[seq_len(nr_header), , drop = FALSE]) - - ft <- merge_at_indice(ft, lst = merge_index_body, part = "body") - ft <- merge_at_indice(ft, lst = merge_index_header, part = "header") - ft <- flextable::align_text_col(ft, align = "center", header = TRUE) - ft <- flextable::align(ft, i = seq_len(nrow(content)), j = 1, align = "left") - ft <- padding_lst(ft, mf$row_info$indent) - ft <- flextable::padding(ft, padding.top = 1, padding.bottom = 1, part = "all") - ft <- flextable::autofit(ft, add_h = 0) - - width_vector <- c( - dim(ft)$widths[1], - rep(sum(dim(ft)$widths[-1]), length(dim(ft)$widths) - 1) / (ncol(mf$strings) - 1) - ) - ft <- flextable::width(ft, width = width_vector) - ft <- custom_theme(ft) - - # Add footers - ft <- flextable::add_footer_lines(ft, flextable::as_paragraph( - flextable::as_chunk(mf$main_footer, props = flextable::fp_text_default(font.size = 8)) - )) - if (length(mf$main_footer) > 0 && length(mf$prov_footer) > 0) ft <- flextable::add_footer_lines(ft, c("\n")) - ft <- flextable::add_footer_lines(ft, flextable::as_paragraph( - flextable::as_chunk(mf$prov_footer, props = flextable::fp_text_default(font.size = 8)) - )) } else if (inherits(content, "data.frame")) { - ft <- flextable::flextable(content) - ft <- custom_theme(ft) + ft <- rtables::df_to_tt(content) + content <- ft + ft <- rtables::tt_to_flextable(ft) } else { stop(paste0("Unsupported class `(", format(class(content)), ")` when exporting table")) } - if (flextable::flextable_dim(ft)$widths > 10) { - pgwidth <- 10.5 - width_vector <- dim(ft)$widths * pgwidth / flextable::flextable_dim(ft)$widths - ft <- flextable::width(ft, width = width_vector) - } - - ft -} + ft <- rtables::theme_docx_default(tt = content)(ft) -#' Apply a custom theme to a `flextable` -#' @noRd -#' @keywords internal -custom_theme <- function(ft) { - checkmate::assert_class(ft, "flextable") - ft <- flextable::fontsize(ft, size = 8, part = "body") - ft <- flextable::bold(ft, part = "header") - ft <- flextable::theme_booktabs(ft) - ft <- flextable::hline(ft, border = flextable::fp_border_default(width = 1, color = "grey")) - ft <- flextable::border_outer(ft) ft } @@ -214,40 +171,6 @@ get_merge_index_single <- function(span) { return(ret) } -#' Get the merge index for multiple spans. -#' This function merges cells in a `flextable` at specified row and column indices. -#' @noRd -#' @keywords internal -get_merge_index <- function(spans) { - ret <- lapply(seq_len(nrow(spans)), function(i) { - ri <- spans[i, ] - r <- get_merge_index_single(ri) - lapply(r, function(s) { - list(j = s, i = i) - }) - }) - unlist(ret, recursive = FALSE, use.names = FALSE) -} - -#' Merge cells in a `flextable` at specified indices -#' @noRd -#' @keywords internal -merge_at_indice <- function(ft, lst, part) { - Reduce(function(ft, ij) { - flextable::merge_at(ft, i = ij$i, j = ij$j, part = part) - }, lst, ft) -} - -#' Apply padding to a `flextable` based on indentation levels. -#' This function applies padding to a `flextable` based on indentation levels provided as a vector. -#' @noRd -#' @keywords internal -padding_lst <- function(ft, indents) { - Reduce(function(ft, s) { - flextable::padding(ft, s, 1, padding.left = (indents[s] + 1) * 10) - }, seq_len(length(indents)), ft) -} - #' Divide text block into smaller blocks #' #' Split a text block into smaller blocks with a specified number of lines. diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index a21b8a34..6d240e62 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -17,42 +17,6 @@ testthat::test_that("to_flextable: unsupported class", { testthat::expect_error(to_flextable(unsupported_data), "Unsupported class") }) -testthat::test_that("custom_theme to flextable", { - sample_ft <- flextable::qflextable(head(mtcars)) - themed_ft <- custom_theme(sample_ft) - testthat::expect_is(themed_ft, "flextable") -}) - -testthat::test_that("get_merge_index_single", { - sample_span <- c(1, 2, 1, 3) - merge_index <- get_merge_index_single(sample_span) - testthat::expect_is(merge_index, "list") -}) - -testthat::test_that("get_merge_index", { - sample_spans <- matrix(c(1, 2, 1, 3, 2, 1, 1, 1), ncol = 2) - merge_index <- get_merge_index(sample_spans) - testthat::expect_is(merge_index, "list") -}) - -testthat::test_that("merge_at_indice", { - sample_ft <- flextable::qflextable(head(mtcars)) - merge_indices <- list( - list(i = 1, j = 1:2), - list(i = 2, j = 3:4) - ) - merged_ft <- merge_at_indice(sample_ft, lst = merge_indices, part = "body") - testthat::expect_is(merged_ft, "flextable") -}) - -testthat::test_that("padding_lst applies padding to a flextable based on indentation levels", { - sample_ft <- flextable::qflextable(head(mtcars)) - sample_indents <- c(1, 2, 1, 3, 2) - padded_ft <- padding_lst(sample_ft, sample_indents) - testthat::expect_is(padded_ft, "flextable") -}) - - testthat::test_that("split_text_block - splits text block into blocks no longer than n lines", { l <- 5 block_text <- paste(paste(rep("Line", l), seq_len(l)), collapse = "\n") From d5cf839caf5b1237ae0977a4f71b45978d4bfd04 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:01:59 +0000 Subject: [PATCH 02/14] [skip style] [skip vbump] Restyle files --- R/utils.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index e37463a2..8ceadcf8 100644 --- a/R/utils.R +++ b/R/utils.R @@ -140,7 +140,6 @@ to_flextable <- function(content) { rtables::header_section_div(ft) <- mf$header_section_div content <- ft ft <- rtables::tt_to_flextable(ft, total_width = c(grDevices::pdf.options()$width - 1)) - } else if (inherits(content, "data.frame")) { ft <- rtables::df_to_tt(content) content <- ft From 613f4e81ab77aa8880eb48d061fa8e80e316171b Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Wed, 15 May 2024 17:19:28 +0530 Subject: [PATCH 03/14] removed theme. --- R/utils.R | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/R/utils.R b/R/utils.R index 4dd11b78..6af45e83 100644 --- a/R/utils.R +++ b/R/utils.R @@ -138,18 +138,15 @@ to_flextable <- function(content) { rtables::main_footer(ft) <- mf$main_footer rtables::prov_footer(ft) <- mf$prov_footer rtables::header_section_div(ft) <- mf$header_section_div - content <- ft ft <- rtables::tt_to_flextable(ft, total_width = c(grDevices::pdf.options()$width - 1)) } else if (inherits(content, "data.frame")) { - ft <- rtables::df_to_tt(content) - content <- ft - ft <- rtables::tt_to_flextable(ft) + ft <- rtables::tt_to_flextable( + rtables::df_to_tt(content) + ) } else { stop(paste0("Unsupported class `(", format(class(content)), ")` when exporting table")) } - ft <- rtables::theme_docx_default(tt = content)(ft) - ft } From 6d72b606f562735ef1878ee144f85f93807f0219 Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Wed, 15 May 2024 17:38:52 +0530 Subject: [PATCH 04/14] increasing threshold --- .github/workflows/check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index b84e2738..7670cf98 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -27,7 +27,7 @@ jobs: with: additional-env-vars: | _R_CHECK_CRAN_INCOMING_REMOTE_=false - _R_CHECK_EXAMPLE_TIMING_THRESHOLD_=10 + _R_CHECK_EXAMPLE_TIMING_THRESHOLD_=11 additional-r-cmd-check-params: --as-cran enforce-note-blocklist: true note-blocklist: | From 2a68bf233fb2993005cf59064b251490c1b8b9c7 Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Wed, 15 May 2024 21:33:06 +0530 Subject: [PATCH 05/14] call. rlistings::matrix_form --- R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index 6af45e83..6873a0f9 100644 --- a/R/utils.R +++ b/R/utils.R @@ -127,7 +127,7 @@ to_flextable <- function(content) { if (inherits(content, c("rtables", "TableTree", "ElementaryTable"))) { ft <- rtables::tt_to_flextable(content) } else if (inherits(content, "listing_df")) { - mf <- rtables::matrix_form(content) + mf <- rlistings::matrix_form(content) nr_header <- attr(mf, "nrow_header") df <- as.data.frame(mf$strings[seq(nr_header + 1, nrow(mf$strings)), , drop = FALSE]) header_df <- as.data.frame(mf$strings[seq_len(nr_header), , drop = FALSE]) From 5643a94bd7a7e51bdeafc401bb82deacfe9d65ac Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Wed, 15 May 2024 21:45:34 +0530 Subject: [PATCH 06/14] adding rlistings to import --- DESCRIPTION | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b5a47661..31f6bd63 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,6 +30,7 @@ Imports: knitr (>= 1.34), lifecycle (>= 0.2.0), R6, + rlistings (>= 0.2.8), rmarkdown (>= 2.19), rtables (>= 0.5.1), shiny (>= 1.6.0), @@ -52,9 +53,9 @@ RdMacros: lifecycle Config/Needs/verdepcheck: rstudio/bslib, mllg/checkmate, davidgohel/flextable, rstudio/htmltools, yihui/knitr, r-lib/lifecycle, - r-lib/R6, rstudio/rmarkdown, rstudio/shiny, dreamRs/shinybusy, - dreamRs/shinyWidgets, yaml=vubiostat/r-yaml, r-lib/zip, rstudio/DT, - yihui/formatR, tidyverse/ggplot2, deepayan/lattice, cran/png, + r-lib/R6, insightsengineering/rlistings, rstudio/rmarkdown, rstudio/shiny, + dreamRs/shinybusy, dreamRs/shinyWidgets, yaml=vubiostat/r-yaml, r-lib/zip, + rstudio/DT, yihui/formatR, tidyverse/ggplot2, deepayan/lattice, cran/png, insightsengineering/rtables, r-lib/testthat, rstudio/tinytex, r-lib/withr Config/Needs/website: insightsengineering/nesttemplate From 428376322f52303e653ee32154529ef796f794ed Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Wed, 15 May 2024 21:59:06 +0530 Subject: [PATCH 07/14] fixing styling and arranging the imports and suggests pacakges. --- DESCRIPTION | 16 ++++++++-------- R/LoadReporterModule.R | 1 - R/SimpleReporter.R | 7 ++----- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 31f6bd63..5b4ecb3a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,6 +29,7 @@ Imports: htmltools (>= 0.5.4), knitr (>= 1.34), lifecycle (>= 0.2.0), + png, R6, rlistings (>= 0.2.8), rmarkdown (>= 2.19), @@ -43,7 +44,6 @@ Suggests: formatR (>= 1.5), ggplot2 (>= 3.4.0), lattice (>= 0.18-4), - png, testthat (>= 3.1.5), tinytex, withr (>= 2.0.0) @@ -51,13 +51,13 @@ VignetteBuilder: knitr RdMacros: lifecycle -Config/Needs/verdepcheck: rstudio/bslib, mllg/checkmate, - davidgohel/flextable, rstudio/htmltools, yihui/knitr, r-lib/lifecycle, - r-lib/R6, insightsengineering/rlistings, rstudio/rmarkdown, rstudio/shiny, - dreamRs/shinybusy, dreamRs/shinyWidgets, yaml=vubiostat/r-yaml, r-lib/zip, - rstudio/DT, yihui/formatR, tidyverse/ggplot2, deepayan/lattice, cran/png, - insightsengineering/rtables, r-lib/testthat, rstudio/tinytex, - r-lib/withr +Config/Needs/verdepcheck: rstudio/bslib, mllg/checkmate, + davidgohel/flextable, cran/grid, rstudio/htmltools, yihui/knitr, + r-lib/lifecycle, cran/png, r-lib/R6, insightsengineering/rlistings, + rstudio/rmarkdown, insightsengineering/rtables, rstudio/shiny, + dreamRs/shinybusy, dreamRs/shinyWidgets, vubiostat/r-yaml, r-lib/zip, + rstudio/DT, yihui/formatR, tidyverse/ggplot2, deepayan/lattice, + r-lib/testthat, rstudio/tinytex, r-lib/withr Config/Needs/website: insightsengineering/nesttemplate Encoding: UTF-8 Language: en-US diff --git a/R/LoadReporterModule.R b/R/LoadReporterModule.R index 2e8a1ff7..7043275d 100644 --- a/R/LoadReporterModule.R +++ b/R/LoadReporterModule.R @@ -132,7 +132,6 @@ load_json_report <- function(reporter, zip_path, filename) { ) } ) - } else { shiny::showNotification("Failed to load the Reporter file.", type = "error") } diff --git a/R/SimpleReporter.R b/R/SimpleReporter.R index c912da38..3aef137c 100644 --- a/R/SimpleReporter.R +++ b/R/SimpleReporter.R @@ -36,9 +36,7 @@ NULL #' @rdname simple_reporter #' @export -simple_reporter_ui <- function( - id -) { +simple_reporter_ui <- function(id) { ns <- shiny::NS(id) shiny::tagList( shiny::singleton( @@ -73,8 +71,7 @@ simple_reporter_srv <- function( author = "NEST", title = "Report", date = as.character(Sys.Date()), output = "html_document", toc = FALSE - ) -) { + )) { shiny::moduleServer( id, function(input, output, session) { From 56312de36de04cce58eb0a6e9eb625ccab53d991 Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Wed, 15 May 2024 23:17:02 +0530 Subject: [PATCH 08/14] reverting changes on png pkg --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5b4ecb3a..aefd6291 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,7 +29,6 @@ Imports: htmltools (>= 0.5.4), knitr (>= 1.34), lifecycle (>= 0.2.0), - png, R6, rlistings (>= 0.2.8), rmarkdown (>= 2.19), @@ -43,6 +42,7 @@ Suggests: DT (>= 0.13), formatR (>= 1.5), ggplot2 (>= 3.4.0), + png, lattice (>= 0.18-4), testthat (>= 3.1.5), tinytex, From 800d071a493311adbeff15c514db5d13584b0915 Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Thu, 16 May 2024 18:46:10 +0530 Subject: [PATCH 09/14] adding tests for different classes. --- tests/testthat/test-utils.R | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 6d4db177..35c42c49 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -6,13 +6,23 @@ testthat::test_that("panel_item", { testthat::expect_s3_class(panel_item("LABEL", shiny::tags$div()), "shiny.tag") }) -testthat::test_that("to_flextable: supported class", { +testthat::test_that("to_flextable: supported class `data.frame`", { data_frame <- data.frame(A = 1:3, B = 4:6) - # https://github.com/davidgohel/flextable/issues/600 - withr::with_options( - opts_partial_match_old, - flextable_output <- to_flextable(data_frame) - ) + flextable_output <- to_flextable(data_frame) + testthat::expect_s3_class(flextable_output, "flextable") +}) + +testthat::test_that("to_flextable: supported class `rtables`", { + tbl <- basic_table() %>% + analyze("AGE", afun = mean) %>% + build_table( DM) + flextable_output <- to_flextable(tbl) + testthat::expect_s3_class(flextable_output, "flextable") +}) + +testthat::test_that("to_flextable: supported class `listing_df`", { + lsting <- rlistings::as_listing(formatters::ex_adae[1:25,], main_title = "lsting") + flextable_output <- to_flextable(lsting) testthat::expect_s3_class(flextable_output, "flextable") }) From bbfc43043540e272d8d8b54227880d28e591f745 Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Thu, 16 May 2024 18:51:28 +0530 Subject: [PATCH 10/14] fixing listing blank title issue. --- R/utils.R | 4 +++- tests/testthat/test-utils.R | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/utils.R b/R/utils.R index 6873a0f9..363b6d74 100644 --- a/R/utils.R +++ b/R/utils.R @@ -133,7 +133,9 @@ to_flextable <- function(content) { header_df <- as.data.frame(mf$strings[seq_len(nr_header), , drop = FALSE]) ft <- rtables::df_to_tt(df) - rtables::main_title(ft) <- mf$main_title + if (length(mf$main_title) != 0) { + rtables::main_title(ft) <- mf$main_title + } rtables::subtitles(ft) <- mf$subtitles rtables::main_footer(ft) <- mf$main_footer rtables::prov_footer(ft) <- mf$prov_footer diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 35c42c49..40cb3d78 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -21,7 +21,7 @@ testthat::test_that("to_flextable: supported class `rtables`", { }) testthat::test_that("to_flextable: supported class `listing_df`", { - lsting <- rlistings::as_listing(formatters::ex_adae[1:25,], main_title = "lsting") + lsting <- rlistings::as_listing(formatters::ex_adae[1:25,]) flextable_output <- to_flextable(lsting) testthat::expect_s3_class(flextable_output, "flextable") }) From 0363f1a4cd9b9354f3b7aaa6c47f159434298933 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 13:23:32 +0000 Subject: [PATCH 11/14] [skip style] [skip vbump] Restyle files --- tests/testthat/test-utils.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 40cb3d78..436b3c21 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -15,13 +15,13 @@ testthat::test_that("to_flextable: supported class `data.frame`", { testthat::test_that("to_flextable: supported class `rtables`", { tbl <- basic_table() %>% analyze("AGE", afun = mean) %>% - build_table( DM) + build_table(DM) flextable_output <- to_flextable(tbl) testthat::expect_s3_class(flextable_output, "flextable") }) testthat::test_that("to_flextable: supported class `listing_df`", { - lsting <- rlistings::as_listing(formatters::ex_adae[1:25,]) + lsting <- rlistings::as_listing(formatters::ex_adae[1:25, ]) flextable_output <- to_flextable(lsting) testthat::expect_s3_class(flextable_output, "flextable") }) From fb9751a34f890667d7cd3da6db8d9e9a79144e43 Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Thu, 16 May 2024 19:00:50 +0530 Subject: [PATCH 12/14] fixing tests --- tests/testthat/test-utils.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 40cb3d78..0789d0f3 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -13,15 +13,15 @@ testthat::test_that("to_flextable: supported class `data.frame`", { }) testthat::test_that("to_flextable: supported class `rtables`", { - tbl <- basic_table() %>% - analyze("AGE", afun = mean) %>% - build_table( DM) + tbl <- rtables::basic_table() %>% + rtables::analyze("AGE", afun = mean) %>% + rtables::build_table( DM) flextable_output <- to_flextable(tbl) testthat::expect_s3_class(flextable_output, "flextable") }) testthat::test_that("to_flextable: supported class `listing_df`", { - lsting <- rlistings::as_listing(formatters::ex_adae[1:25,]) + lsting <- rlistings::as_listing(iris) flextable_output <- to_flextable(lsting) testthat::expect_s3_class(flextable_output, "flextable") }) From be768f058a6348f649c79ae8c8ff75a6d745c0f2 Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Thu, 16 May 2024 19:11:54 +0530 Subject: [PATCH 13/14] adding formatters in suggests --- DESCRIPTION | 1 + tests/testthat/test-utils.R | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index aefd6291..56bda02d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -41,6 +41,7 @@ Imports: Suggests: DT (>= 0.13), formatR (>= 1.5), + formatters, ggplot2 (>= 3.4.0), png, lattice (>= 0.18-4), diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 839a3227..60dba680 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -15,13 +15,13 @@ testthat::test_that("to_flextable: supported class `data.frame`", { testthat::test_that("to_flextable: supported class `rtables`", { tbl <- rtables::basic_table() %>% rtables::analyze("AGE", afun = mean) %>% - rtables::build_table(DM) + rtables::build_table(formatters::DM) flextable_output <- to_flextable(tbl) testthat::expect_s3_class(flextable_output, "flextable") }) testthat::test_that("to_flextable: supported class `listing_df`", { - lsting <- rlistings::as_listing(iris) + lsting <- rlistings::as_listing(formatters::ex_adae[1:50,]) flextable_output <- to_flextable(lsting) testthat::expect_s3_class(flextable_output, "flextable") }) From d493bd804d5552f19fa07ba2759b4c939ab72644 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 13:44:00 +0000 Subject: [PATCH 14/14] [skip style] [skip vbump] Restyle files --- tests/testthat/test-utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 60dba680..7be3a86c 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -21,7 +21,7 @@ testthat::test_that("to_flextable: supported class `rtables`", { }) testthat::test_that("to_flextable: supported class `listing_df`", { - lsting <- rlistings::as_listing(formatters::ex_adae[1:50,]) + lsting <- rlistings::as_listing(formatters::ex_adae[1:50, ]) flextable_output <- to_flextable(lsting) testthat::expect_s3_class(flextable_output, "flextable") })