latexr-markdownkablekableextra

Citing within an RMarkdown table


I am attempting to create a table which has citations built into the table. Here is a visual of what I am trying to achieve.

desired output

As far as I know you can only add footnotes in rowvars or colvars in kableExtra (love that package).

# Create a dataframe called df
Component <- c('N2','P3')
Latency <- c('150 to 200ms', '625 to 800ms')
Location <- c('FCz, Fz, Cz', 'Pz, Oz')
df <- data.frame(Component, Latency, Location)

Below is my attempt after reading through kableExtra's Git page

# Trying some code taken from the kableExtra guide
row.names(df) <- df$Component
df[1] <- NULL
dt_footnote <- df
names(dt_footnote)[1] <- paste0(names(dt_footnote)[2],
                                footnote_marker_symbol(1))

row.names(dt_footnote)[2] <- paste0(row.names(dt_footnote)[2], 
                                footnote_marker_alphabet(1))
kable(dt_footnote, align = "c", 
      # Remember this escape = F
      escape = F, "latex", longtable = T, booktabs = T, caption = "My Table Name") %>%
  kable_styling(full_width = F) %>%
  footnote(alphabet = "Jones, 2013",
           symbol = "Footnote Symbol 1; ",
           footnote_as_chunk = T)

Output

But this code only works on the headers. The ultimate goal would be if I could use a BibTex reference such as @JonesFunctionalMixedEffectModels2013 such that the final part of the code would look like

footnote(alphabet = @davidsonFunctionalMixedEffectModels2009,
           symbol = "Footnote Symbol 1; ", footnote_as_chunk = T)

Anyone have any ideas?

Thanks


Solution

  • What I did at the end was to generate a temporary table with pander, then copy the references' number manually to my kable

    pander(
      df,
      caption = "Temporal",
      style = "simple",
      justify = "left")