简体   繁体   中英

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

在此处输入图像描述

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.

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("‡"))

在此处输入图像描述

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 (eg, 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 (eg, I use "† ", "‡ ", "A" or "B") and I add number-footnote-symbol when it come next to a text (eg, ¹ or ²).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM