diff --git a/DESCRIPTION b/DESCRIPTION index 816743d8..9843402d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,36 +1,45 @@ -Package: flextable Type: Package +Package: flextable Title: Functions for Tabular Reporting -Version: 0.9.6.010 +Version: 0.9.6.011 Authors@R: c( - person("David", "Gohel", role = c("aut", "cre"), - email = "david.gohel@ardata.fr"), - person(given = "ArData", role = "cph"), + person("David", "Gohel", , "david.gohel@ardata.fr", role = c("aut", "cre")), + person("ArData", role = "cph"), person("Clementine", "Jager", role = "ctb"), - person("Panagiotis", "Skintzos", role = "aut", email = "panagiotis.skintzos@ardata.fr"), + person("Panagiotis", "Skintzos", , "panagiotis.skintzos@ardata.fr", role = "aut"), person("Quentin", "Fazilleau", role = "ctb"), - person("Maxim", "Nazarov", role = "ctb", comment = "rmarkdown for docx output"), + person("Maxim", "Nazarov", role = "ctb", + comment = "rmarkdown for docx output"), person("Titouan", "Robert", role = "ctb"), - person("Michael", "Barrowman", role = "ctb", comment = "inline footnotes"), - person("Atsushi", "Yasumoto", role = "ctb", comment = "support for bookdown cross reference"), - person("Paul", "Julian", role = "ctb", comment = "support for gam objects"), - person("Sean", "Browning", role = "ctb", comment = "work on footnote positioning system"), - person("Rémi", "Thériault", role = "ctb", comment = c(ORCID = "0000-0003-4315-6788", ctb = "theme_apa")), - person("Samuel", "Jobert", role = "ctb", comment = "work on pagination"), + person("Michael", "Barrowman", role = "ctb", + comment = "inline footnotes"), + person("Atsushi", "Yasumoto", role = "ctb", + comment = "support for bookdown cross reference"), + person("Paul", "Julian", role = "ctb", + comment = "support for gam objects"), + person("Sean", "Browning", role = "ctb", + comment = "work on footnote positioning system"), + person("Rémi", "Thériault", role = "ctb", + comment = c(ORCID = "0000-0003-4315-6788", ctb = "theme_apa")), + person("Samuel", "Jobert", role = "ctb", + comment = "work on pagination"), person("Keith", "Newman", role = "ctb") - ) + ) Description: Use a grammar for creating and customizing pretty tables. - The following formats are supported: 'HTML', 'PDF', 'RTF', - 'Microsoft Word', 'Microsoft PowerPoint' and R 'Grid Graphics'. - 'R Markdown', 'Quarto' and the package 'officer' can be used to produce - the result files. The syntax is the same for the user regardless of - the type of output to be produced. A set of functions allows the - creation, definition of cell arrangement, addition of headers or - footers, formatting and definition of cell content with text and - or images. The package also offers a set of high-level functions - that allow tabular reporting of statistical models and the - creation of complex cross tabulations. + The following formats are supported: 'HTML', 'PDF', 'RTF', 'Microsoft + Word', 'Microsoft PowerPoint' and R 'Grid Graphics'. 'R Markdown', + 'Quarto' and the package 'officer' can be used to produce the result + files. The syntax is the same for the user regardless of the type of + output to be produced. A set of functions allows the creation, + definition of cell arrangement, addition of headers or footers, + formatting and definition of cell content with text and or images. The + package also offers a set of high-level functions that allow tabular + reporting of statistical models and the creation of complex cross + tabulations. License: GPL-3 +URL: https://ardata-fr.github.io/flextable-book/, + https://davidgohel.github.io/flextable/ +BugReports: https://github.com/davidgohel/flextable/issues Imports: data.table (>= 1.13.0), gdtools (>= 0.3.6), @@ -47,14 +56,12 @@ Imports: utils, uuid (>= 0.1-4), xml2 -RoxygenNote: 7.3.1 -Roxygen: list(markdown = TRUE) Suggests: bookdown (>= 0.34), broom, broom.mixed, - cluster, chromote, + cluster, commonmark, doconv (>= 0.3.0), equatags, @@ -69,11 +76,13 @@ Suggests: scales, svglite, tables (>= 0.9.17), - testthat (>= 2.1.0), + testthat (>= 3.0.0), webshot2, withr, xtable +VignetteBuilder: + knitr +Config/testthat/edition: 3 Encoding: UTF-8 -URL: https://ardata-fr.github.io/flextable-book/, https://davidgohel.github.io/flextable/ -BugReports: https://github.com/davidgohel/flextable/issues -VignetteBuilder: knitr +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.3.1 diff --git a/man/flextable-package.Rd b/man/flextable-package.Rd index 9d9b5d6c..ae6f6687 100644 --- a/man/flextable-package.Rd +++ b/man/flextable-package.Rd @@ -50,6 +50,7 @@ Other contributors: \item Sean Browning (work on footnote positioning system) [contributor] \item Rémi Thériault (\href{https://orcid.org/0000-0003-4315-6788}{ORCID}) (theme_apa) [contributor] \item Samuel Jobert (work on pagination) [contributor] + \item Keith Newman [contributor] } } diff --git a/tests/testthat/test-as_flextable.R b/tests/testthat/test-as_flextable.R index 070436f7..bd6a4082 100644 --- a/tests/testthat/test-as_flextable.R +++ b/tests/testthat/test-as_flextable.R @@ -1,5 +1,3 @@ -context("check as_flextable") - test_that("data.frame", { dummy_df <- data.frame( A = rep(letters[1:3], each = 2), diff --git a/tests/testthat/test-borders.R b/tests/testthat/test-borders.R index df37b7ff..a777ed39 100644 --- a/tests/testthat/test-borders.R +++ b/tests/testthat/test-borders.R @@ -1,5 +1,3 @@ -context("check borders rendering") - init_flextable_defaults() snap_folder_test_file <- "borders" defer_cleaning_snapshot_directory(snap_folder_test_file) diff --git a/tests/testthat/test-captions-rmd.R b/tests/testthat/test-captions-rmd.R index 84a5bfaf..85d13340 100644 --- a/tests/testthat/test-captions-rmd.R +++ b/tests/testthat/test-captions-rmd.R @@ -1,5 +1,3 @@ -context("check captions") - init_flextable_defaults() rmd_file_0 <- "rmd/captions.Rmd" diff --git a/tests/testthat/test-cell_content.R b/tests/testthat/test-cell_content.R index 6efa475c..4c9ef185 100644 --- a/tests/testthat/test-cell_content.R +++ b/tests/testthat/test-cell_content.R @@ -1,5 +1,3 @@ -context("check cell content") - test_that("void works as expected", { expect_error(void(12, part = "all")) @@ -42,7 +40,7 @@ test_that("flextable_defaults values for cell content", { "1 116 933", "dark", "01/01/2011 09:09:09", "Adrien Dupuy", "29 02 2028", "2", "53,58175", "167,7560", "1 009 038", "dark", "01/01/2011 09:09:09" ) - expect_equivalent(object = information_data_chunk(ft)$txt, expected) + expect_equal(object = information_data_chunk(ft)$txt, expected, ignore_attr = TRUE) init_flextable_defaults() }) @@ -79,7 +77,7 @@ test_that("colformat_* functions", { "-26/02/2011-", "-c-", "-b-", "-12,566-", "-4-", "-NON-", "-01/01/2011 090905-", "-27/02/2011-" ) - expect_equivalent(object = information_data_chunk(ft)$txt, expected) + expect_equal(object = information_data_chunk(ft)$txt, expected, ignore_attr = TRUE) ft <- colformat_num(x = ft, big.mark = "", decimal.mark = ".", prefix = "+", suffix = "+") expected <- @@ -91,7 +89,7 @@ test_that("colformat_* functions", { "-26/02/2011-", "-c-", "-b-", "+12.566371+", "+4+", "-NON-", "-01/01/2011 090905-", "-27/02/2011-" ) - expect_equivalent(object = information_data_chunk(ft)$txt, expected) + expect_equal(object = information_data_chunk(ft)$txt, expected, ignore_attr = TRUE) }) diff --git a/tests/testthat/test-df_printer.R b/tests/testthat/test-df_printer.R index b5a242a0..e9598121 100644 --- a/tests/testthat/test-df_printer.R +++ b/tests/testthat/test-df_printer.R @@ -1,5 +1,3 @@ -context("df_printer and utilities") - test_that("use_model_printer and use_df_printer works", { rmd_file <- tempfile(fileext = ".Rmd") file.copy("rmd/use-printer.Rmd", rmd_file) diff --git a/tests/testthat/test-dimensions.R b/tests/testthat/test-dimensions.R index a90e1a4e..5476fb66 100644 --- a/tests/testthat/test-dimensions.R +++ b/tests/testthat/test-dimensions.R @@ -1,5 +1,3 @@ -context("check widths and heights") - test_that("dimensions are valid", { dummy_df <- data.frame(my_col = rep(letters[1:3], each = 2), stringsAsFactors = FALSE) ft <- flextable(dummy_df) diff --git a/tests/testthat/test-errors.R b/tests/testthat/test-errors.R index 702373db..383a2dbb 100644 --- a/tests/testthat/test-errors.R +++ b/tests/testthat/test-errors.R @@ -1,6 +1,3 @@ -context("check errors") - - test_that("rows selections", { dummy_df <- data.frame( my_col = rep(letters[1:3], each = 2), diff --git a/tests/testthat/test-footers.R b/tests/testthat/test-footers.R index c501e31f..5013a633 100644 --- a/tests/testthat/test-footers.R +++ b/tests/testthat/test-footers.R @@ -1,5 +1,3 @@ -context("check footers") - test_that("add_footer", { data_ref <- structure( list( diff --git a/tests/testthat/test-footnote.R b/tests/testthat/test-footnote.R index 0454cb93..6a1ded76 100644 --- a/tests/testthat/test-footnote.R +++ b/tests/testthat/test-footnote.R @@ -1,5 +1,3 @@ -context("check footnotes") - ft <- flextable(iris[1:5, ]) ft <- footnote( x = ft, i = 1:3, j = 1:3, diff --git a/tests/testthat/test-gen_grob.R b/tests/testthat/test-gen_grob.R index 8fff0b0e..f31d2d49 100644 --- a/tests/testthat/test-gen_grob.R +++ b/tests/testthat/test-gen_grob.R @@ -1,5 +1,3 @@ -context("check grid grob") - gdtools::register_liberationsans() init_flextable_defaults() diff --git a/tests/testthat/test-headers.R b/tests/testthat/test-headers.R index e421783f..370a8804 100644 --- a/tests/testthat/test-headers.R +++ b/tests/testthat/test-headers.R @@ -1,5 +1,3 @@ -context("check headers") - test_that("set_header_labels", { col_keys <- c( "Species", diff --git a/tests/testthat/test-images.R b/tests/testthat/test-images.R index 68ed157d..bb98c317 100644 --- a/tests/testthat/test-images.R +++ b/tests/testthat/test-images.R @@ -1,5 +1,3 @@ -context("check images") - data <- iris[c(1:3, 51:53, 101:104), ] col_keys <- c("Species", "sep_1", "Sepal.Length", "Sepal.Width", "sep_2", "Petal.Length", "Petal.Width") img.file <- file.path(R.home("doc"), "html", "logo.jpg") @@ -107,16 +105,16 @@ test_that("multiple images", { } zz <- gen_grob(ft) - expect_is(zz$children$cell_1_1$children$contents$ftgrobs[[1]], "rastergrob") - expect_is(zz$children$cell_2_1$children$contents$ftgrobs[[1]], "rastergrob") - expect_is(zz$children$cell_3_1$children$contents$ftgrobs[[1]], "rastergrob") + expect_s3_class(zz$children$cell_1_1$children$contents$ftgrobs[[1]], "rastergrob") + expect_s3_class(zz$children$cell_2_1$children$contents$ftgrobs[[1]], "rastergrob") + expect_s3_class(zz$children$cell_3_1$children$contents$ftgrobs[[1]], "rastergrob") ft <- flextable(df) ft <- colformat_image(ft, j = "plot", width = 300 / 72, height = 300 / 72) zz <- gen_grob(ft) - expect_is(zz$children$cell_1_1$children$contents$ftgrobs[[1]], "text") - expect_is(zz$children$cell_2_1$children$contents$ftgrobs[[1]], "rastergrob") - expect_is(zz$children$cell_3_1$children$contents$ftgrobs[[1]], "rastergrob") + expect_s3_class(zz$children$cell_1_1$children$contents$ftgrobs[[1]], "text") + expect_s3_class(zz$children$cell_2_1$children$contents$ftgrobs[[1]], "rastergrob") + expect_s3_class(zz$children$cell_3_1$children$contents$ftgrobs[[1]], "rastergrob") }) test_that("minibar", { @@ -131,14 +129,14 @@ test_that("minibar", { part = "body" ) minibar1 <- flextable::information_data_chunk(ft)$img_data[[2]] - expect_is(minibar1, "raster") + expect_s3_class(minibar1, "raster") expect_equal(nrow(minibar1), 1) expect_equal(ncol(minibar1), 36) expect_equal(minibar1[1:3], rep("#FF0000", 3)) expect_equal(minibar1[4:36], rep("#FFFF00", 33)) minibar2 <- flextable::information_data_chunk(ft)$img_data[[3]] - expect_is(minibar2, "raster") + expect_s3_class(minibar2, "raster") expect_equal(nrow(minibar2), 1) expect_equal(ncol(minibar2), 36) expect_equal(minibar2[1:7], rep("#FF0000", 7)) diff --git a/tests/testthat/test-keep_next.R b/tests/testthat/test-keep_next.R index 658fe3a3..fc5daa8c 100644 --- a/tests/testthat/test-keep_next.R +++ b/tests/testthat/test-keep_next.R @@ -1,5 +1,3 @@ -context("check keep with next") - init_flextable_defaults() iris_sum <- summarizor(iris, by = "Species") diff --git a/tests/testthat/test-latex.R b/tests/testthat/test-latex.R index 2baad649..c740b44e 100644 --- a/tests/testthat/test-latex.R +++ b/tests/testthat/test-latex.R @@ -1,5 +1,3 @@ -context("latex table structure") - test_that("white spaces are protected", { ft <- flextable(data.frame(x = "")) ft <- delete_part(ft, part = "header") diff --git a/tests/testthat/test-link.R b/tests/testthat/test-link.R index 246d05fc..aa113073 100644 --- a/tests/testthat/test-link.R +++ b/tests/testthat/test-link.R @@ -1,5 +1,3 @@ -context("check hyperlink") - data <- data.frame( code = c("X01", "X02"), name = c("X Number 1", "X Number 2"), @@ -24,7 +22,7 @@ test_that("URL are preserved in docx", { rid <- xml_attr(xml_find_all(body, "//w:hyperlink"), "id") rels <- doc$doc_obj$rel_df() urls <- rels[rels$id %in% rid, "target"] - expect_equivalent(urls, sprintf(url_base, data$code)) + expect_equal(urls, sprintf(url_base, data$code), ignore_attr = TRUE) }) test_that("URL are preserved in pptx", { @@ -35,7 +33,7 @@ test_that("URL are preserved in pptx", { rid <- xml_attr(xml_find_all(xml_slide, "//a:hlinkClick"), "id") rels <- doc$slide$get_slide(1)$rel_df() urls <- rels[rels$id %in% rid, "target"] - expect_equivalent(urls, sprintf(url_base, data$code)) + expect_equal(urls, sprintf(url_base, data$code), ignore_attr = TRUE) }) test_that("URL are preserved in html", { @@ -46,5 +44,5 @@ test_that("URL are preserved in html", { str_ <- gsub("