I'm trying to put the symbol * inside the table. So far I manged to put symbols in the header and in the first column, but not inside the table. To be precise I would like to mark all values in a certain row or in a certain column that are less than a fixed value. Can you help? Here's a reproducible example:
dt<- mtcars[,1:6]
dt_footnote <- dt
names(dt_footnote)[2] <- paste0(names(dt_footnote)[2],
footnote_marker_symbol(1))
row.names(dt_footnote)[4] <- paste0(row.names(dt_footnote)[4],
footnote_marker_alphabet(1))
kable(dt_footnote, align = "c",
escape = F) %>%
kable_styling(full_width = F) %>%
footnote(alphabet = "Footnote A; ",
symbol = "Footnote Symbol 1; ",
alphabet_title = "Type II: ", symbol_title = "Type III: ",
footnote_as_chunk = T)
Here's my attempt but it doesnt work:
dt$disp<-ifelse(dt$disp<170,paste0(dt$disp,
footnote_marker_symbol(1)),dt$disp)
Thanks a lot!
I can't reproduce your example, as it throws and error when it runs. However this example should work
library(kableExtra)
library(dplyr)
dt <- mtcars[,1:6]
dt <- dt %>%
mutate(disp = case_when(
disp < 150 ~ paste0(as.character(disp), "*"),
TRUE ~ paste0(disp)
))
kable(dt, align = "c",
escape = F) %>%
kable_styling(full_width = F) %>%
footnote(alphabet = "Footnote A; ",
symbol = "Footnote Symbol 1; ",
alphabet_title = "Type II: ", symbol_title = "Type III: ",
footnote_as_chunk = T)