Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 3, 2024
1 parent f8fea93 commit 5081ee7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions R/export_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,11 @@ print.insight_table <- function(x, ...) {
# find out where we have consecutive duplicated rows
consecutive_dups <- which(out[-1] == out[-length(out)])
if (length(consecutive_dups)) {
# if second to last line is a separator line, *and* we usually also have
# a final line, remove that one
if (.is_separator_line(out[length(out) - 1], empty_line, cross, sep)) {
consecutive_dups <- unique(c(consecutive_dups, length(out) - 1))
}
# copy consecutive duplicated rows into temporary object
tmp <- out[consecutive_dups]
# remove separator and cross signs
Expand Down Expand Up @@ -779,6 +784,20 @@ print.insight_table <- function(x, ...) {
}


.is_separator_line <- function(x, empty_line, cross, sep) {
if (!is.null(empty_line) && nzchar(empty_line)) {
x <- gsub(empty_line, "", x, fixed = TRUE)
}
if (!is.null(cross) && nzchar(cross)) {
x <- gsub(cross, "", x, fixed = TRUE)
}
if (!is.null(sep) && nzchar(sep)) {
x <- gsub(sep, "", x, fixed = TRUE)
}
!nzchar(x)
}


.insert_cross <- function(row, cross, sep, pattern, is_last_row) {
# check if at places where row and column "lines" cross, we need a
# special char. E.g., if columns are separated with "|" and header line
Expand Down

0 comments on commit 5081ee7

Please sign in to comment.