I have the following table:
datasets::mtcars %>%
head(5) %>%
gt() %>%
tab_footnote("Footnote: Go Below",
locations = cells_body(columns = mpg,
rows = c(2))) %>%
tab_source_note("Source:PUT THIS ON TOP")
Which gives me this output:
The problem I am having is that I need the footnotes below the source: changing the position of the code doesn't work either.
datasets::mtcars %>%
head(5) %>%
gt() %>% tab_source_note("Source: PUT THIS ON TOP") %>%
tab_footnote("Footnote: Go Below",
locations = cells_body(columns = mpg,
rows = c(2)))
Desired Output:
Update: This code works but not as intended
custom_css1 <- paste0("
#two .gt_sourcenote {
color: red;
position: absolute;
top: ",240,"px;
}")
custom_css2 <- paste0("
#two .gt_footnote {
color: blue;
position: absolute;
top: ",270,"px;
}")
datasets::mtcars %>%
head(5) %>%
gt(id="two") %>%
tab_footnote("Footnote: Go Below",
locations = cells_body(columns = mpg,
rows = c(2))) %>%
tab_footnote("Footnote2: Go Below2",
locations = cells_body(columns = mpg,
rows = c(5))) %>%
tab_source_note("Source:PUT THIS ON TOP") %>%
opt_css(
css = custom_css1
) %>%
opt_css(
css = custom_css2
)
A couple of days after I asked this question - gt
updated to version 0.6.0 and now the tab_footnote()
function does not need a location.
https://gt.rstudio.com/news/index.html#gt-development-version
#install.packages("gt", repos='http://cran.us.r-project.org')
library(gt)
library(dplyr)
datasets::mtcars %>%
head(5) %>%
gt(id="two") %>%
tab_footnote("Source Note: Go on Top"
) %>%
tab_footnote("Footnote: Go Below",
locations = cells_body(columns = mpg,
rows = c(5)))