This is a very general question. I created a few tables in an R markdown using the gt package. I was wondering how to scale down the table so it fits into the PDF created when I knit the markdown script. I have the following code for the table:
DEGs %>%
filter(FC==2 & package=="edgeR") %>%
select(-Dataset_label, -FC, -FDR, -Condition_1, -Condition_2, -package, -FullGeneBody.Down_genes, -FullGeneBody.Up_genes) %>%
gt() %>%
tab_options(
container.width = pct(85),
container.overflow.x = T,
table.align = "center",
table.width = pct(85),
table.layout = "auto"
)%>%
tab_header(
title = "DEHP and Pb 5 Month ",
subtitle = glue("|FC| > {DEGs$FC[5]} and FDR < {DEGs$FDR[5]}")
) %>%
fmt_number(
columns = comparison
) %>%
#fmt(
#columns = c(Condition_Name_1, Condition_Name_2, Condition_1_GM_Numbers, Condition_2_GM_Numbers)
#)%>%
fmt_number(
columns = c(ExonCollapsed.Down_genes, ExonCollapsed.Up_genes)
) %>%
cols_label(
comparison="Comp",
Condition_Name_1="Condition 1",
Condition_Name_2="Condition 2",
Condition_1_GM_Numbers="Condition 1 #s",
Condition_2_GM_Numbers="Condition 2 #s",
ExonCollapsed.Down_genes="Down Genes",
ExonCollapsed.Up_genes="Up Genes"
)
As you can see I tried using table.align, table.width
etc. to try to resize the table, but none those settings seem to affect the table in the actual PDF.
Thanks for the help.
Edit: Someone asked for me to make the code a reproducible example, and I am uncertain if I can do this with the built-in datasets. i think some of the confusion is because I did not make it clear what happens when I knit the markdown to PDF. So if I just run the code above I get an output like the following:
It is fine with a scroll bar appearing allowing one to see the entire table by scrolling. However when I knit to a PDF I get the following:
As you can hopefully see the table is completely cut off in the PDF.
(Note: to see the images right click on the icon and click open in new tab. My fault I may have linked the images wrong)