From b25eb13902cb7a74b2c0a5cd83e5705c3b073157 Mon Sep 17 00:00:00 2001 From: David Gohel Date: Tue, 9 Jan 2024 23:17:31 +0100 Subject: [PATCH] fix: `footnote()` handle undefined `ref_symbols` argument fix #596 --- DESCRIPTION | 2 +- NEWS.md | 1 + R/footnote.R | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b0433e76..eaef1e6f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: flextable Type: Package Title: Functions for Tabular Reporting -Version: 0.9.5.005 +Version: 0.9.5.006 Authors@R: c( person("David", "Gohel", role = c("aut", "cre"), email = "david.gohel@ardata.fr"), diff --git a/NEWS.md b/NEWS.md index 6b575921..28a0ad53 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ - `summarizor()` don't stop anymore if table only contain discrete columns. - `as_flextable.data.frame()` supports 'data.table' +- `footnote()` handle undefined `ref_symbols` argument ## Changes diff --git a/R/footnote.R b/R/footnote.R index de0f743d..fd1b783e 100644 --- a/R/footnote.R +++ b/R/footnote.R @@ -101,7 +101,7 @@ footnote <- function(x, i = NULL, j = NULL, value, ref_symbols = NULL, part = "b symbols_str <- ref_symbols } - if (any(ref_symbols %in% "")) { + if (any(symbols_str %in% "")) { long_msg <- c( "Usage of empty symbol '' with footnote should not happen, ", "use `add_footer_lines()` instead, it does not require any symbol. ", @@ -144,7 +144,7 @@ footnote <- function(x, i = NULL, j = NULL, value, ref_symbols = NULL, part = "b } paras <- mapply(rbind, - as_paragraph(as_sup(ref_symbols)), + as_paragraph(as_sup()), value, as_paragraph(sep_str), SIMPLIFY = FALSE @@ -158,14 +158,14 @@ footnote <- function(x, i = NULL, j = NULL, value, ref_symbols = NULL, part = "b } } else { # init new lines - x <- add_footer_lines(x, values = ref_symbols) + x <- add_footer_lines(x, values = symbols_str) for (v in seq_along(value)) { # `[<-.chunkset_struct` x[["footer"]]$content[n_row + v, j = 1] <- value[v] x <- prepend_chunks( x = x, i = n_row + v, j = 1, part = "footer", - as_sup(ref_symbols[v]) # [ as we want a list of df + as_sup(symbols_str[v]) # [ as we want a list of df ) } }