Hello, I am having some issues rendering gt
tables while using RMarkdown. The tables print differently when I render them as HTML or PDF documents.
For example when I run the code below
date <- c('2000-01-01',
'2000-01-01',
'2000-01-01',
'2000-01-01',
'2000-01-01')
value <- c(23, 41, 32, 58, 26)
df <- data.frame(date, value)
library(gt)
gt(df) %>%
cols_label(date = 'Date',
value = 'Value') %>%
cols_align(align = 'center') %>%
tab_source_note(
source_note = 'Source: ABC Company'
) %>%
tab_options(
column_labels.border.top.color = 'black',
column_labels.border.top.style = 'solid',
column_labels.border.top.width = 0.5,
table.border.bottom.color = 'black',
table.border.bottom.style = 'solid',
table.border.bottom.width = 0.5,
table.border.left.color = 'black',
table.border.left.style = 'solid',
table.border.left.width = 0.5,
table.border.right.color = 'black',
table.border.right.style = 'solid',
table.border.right.width = 0.5,
)
as an HTML document (output: html_document
) , I get the table on the top, and when I run the code as a PDF document (output: pdf_document
), I get the table on the bottom.
Can someone please help me with this? I would like the PDF table to have the same formatting as the HTML table.
I found a thread with this same issue, but didn't find any solutions Using gt in Markdown and creating a PDF.
Thank you in advance!