Patrick
Patrick

Reputation: 1421

How do I remove a footnote from a huxtable in R?

Once a footnote has been set via add_footnote it seems like its hard to get rid of again.

library(magrittr)
library(huxtable)

jams <- hux(
  Type  = c("Strawberry", "Raspberry", "Plum"),
  Price = c(1.90, 2.10, 1.80)
) %>% add_footnote("Tasty stuff!")

One solution I tried is this:

head(jams, -1)

Unfortunately, the line at the bottom of the huxtable remains. What I would like is a solution which returns a huxtable as if the footnote had never been set.

EDIT: The code below will also remove the line:

jams <- head(jams, -1)
attributes(jams)$tb_borders$thickness[nrow(attributes(jams)$tb_borders$thickness), ] <- 0

I'm not sure how robust this is though.

EDIT: One issue is that if you use this to remove a footnote which was never set then you remove a line of data.

Upvotes: 0

Views: 138

Answers (1)

dash2
dash2

Reputation: 2262

If you want to get rid of the border, just use the relevant function:

jams <- hux(
  Type  = c("Strawberry", "Raspberry", "Plum"),
  Price = c(1.90, 2.10, 1.80)
) %>% add_footnote("Tasty stuff!")

head(jams, -1) %>% set_bottom_border(final(1), everywhere, 0)

Upvotes: 1

Related Questions