frank
frank

Reputation: 3608

is it possible to hide the footnote number reference in flextable footer section and replace with own text

I have a flextable:

df = data.frame(col1 = c(123,234,54,5), col2 = c(NA,1,2,3), col3 = 5:8)
df %>%
  flextable() %>%
  footnote(i = 1, j = 1,
           value = as_paragraph('this is a footnote'),
           ref_symbols = "1",
           part = "body") %>%
  footnote(i = 1, j = 1,
           value = as_paragraph(as_b("Note (2):"),"This is another foonote"),
           ref_symbols = "2",
           part = "body") 

that shows

enter image description here

What I would like to do is keep the flextable and footnotes, but remove the little 1 and 2 that appear in the footer section.

Upvotes: 1

Views: 369

Answers (2)

David Gohel
David Gohel

Reputation: 10695

You can use add_footer_lines() to add any content in a new line and append_chunks() to append any content in existing cells/rows/columns (prepend_chunks() can sometimes be useful)

library(flextable)
df <- data.frame(col1 = c(123,234,54,5), col2 = c(NA,1,2,3), col3 = 5:8)
df |>
  flextable() |>
  add_footer_lines("Here is a foonote") |> 
  add_footer_lines(as_paragraph(as_b("Note (2):"),"This is another foonote")) |> 
  append_chunks(i = 1, j = 1, as_sup("12")) |> 
  append_chunks(i = 2, j = 1, as_sup("‡"))

enter image description here

Upvotes: 1

Cl&#233;ment LVD
Cl&#233;ment LVD

Reputation: 702

The David Gohel's previous answer is fine for not getting this behavior of adding the symbol in the cell and in the footnote, but this previous answer will not add "1" or "2" in the cells of the table. In this case, you have to add these symbols by yourself in the cells, since the footnote func' require a "value" parameter (or you get Error in mapply(function(x, y) { : argument "value" is missing, with no default).

In order to add ¹, ², etc. in the cells of the table, I suggest to use a superscript generator (e.g., here), and a paste0 func' to modify the cells and add the symbol ¹ to the data; then use the add_footer_lines func' to create the footnote that you want, without the symbol at the beginning of the footnote (see David Gohel's previous answer).

PS: for a good readability of the "ref_symbols", I prefer to use letters when the symbol appears next to a number (e.g., I use "† ", "‡ ", "A" or "B") and I add number-footnote-symbol when it come next to a text (e.g., ¹ or ²).

Upvotes: 1

Related Questions