Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 3, 2024
1 parent f9c1d3f commit f8fea93
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
11 changes: 9 additions & 2 deletions R/export_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#' - `options(easystats_table_width = <value>)` can be used to set a default
#' width for tables.
#' @param remove_duplicates Logical, if `TRUE` and table is split into multiple
#' parts, duplicated ("empty") lines will be removed. If `FALSE`, empty lines
#' parts, duplicated ("empty") rows will be removed. If `FALSE`, empty rows
#' will be preserved. Only applies when `table_width` is *not* `NULL` (or
#' `Inf`) *and* table is split into multiple parts.
#' @param ... Currently not used.
Expand Down Expand Up @@ -761,7 +761,14 @@ print.insight_table <- function(x, ...) {
if (remove_duplicated_lines) {
out <- out[-remove_dups]
} else if (!is.null(empty_line) && nzchar(empty_line)) {
out[remove_dups] <- gsub(empty_line, " ", out[remove_dups])
# when consecutive duplicated rows are removed, the different table
# parts may have different height (number of rows). To avoid confusion,
# it is possible to preserve the height of each table part by setting
# remove_duplicates = FALSE
out[remove_dups] <- gsub(empty_line, " ", out[remove_dups], fixed = TRUE)
if (!is.null(sep) && nzchar(sep) && !is.null(cross) && nzchar(cross)) {
out[remove_dups] <- gsub(trim_ws(cross), trim_ws(sep), out[remove_dups], fixed = TRUE)
}
}
# collapse back into single string
rows <- paste0(paste(out, collapse = "\n"), "\n")
Expand Down
2 changes: 1 addition & 1 deletion man/export_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions tests/testthat/_snaps/export_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,16 @@
1 | c12hour | average number of hours of care per week
---+----------+-----------------------------------------
2 | e16sex | elder's gender
+ +
| |
---+----------+-----------------------------------------
3 | e42dep | elder's dependency
+ +
+ +
+ +
| |
| |
| |
---+----------+-----------------------------------------
4 | c172code | carer's level of education
+ +
+ +
| |
| |
---+----------+-----------------------------------------
5 | neg_c_7 | Negative impact with 7 items
--------------------------------------------------------
Expand Down

0 comments on commit f8fea93

Please sign in to comment.