R 如何在特定位置排列表格网格。排列

R 如何在特定位置排列表格网格。排列,r,pdf,grid,r-grid,R,Pdf,Grid,R Grid,我正在使用gtable和gridExtra包来处理PDF。我正在努力为我的桌子手动设置位置,也就是说,我希望两者都在中间,而不是靠近边缘。使用grid.arrange()公式时,将自动设置位置 此外,我想知道如何才能使脚注更偏左,甚至在表格“之前” 如何将布局矩阵()调整为该值 grid.arrange(table1, table) 请参阅简化代码: pdf("mrcars_check.pdf",width = 15, height=10, bg = "white

我正在使用gtable和gridExtra包来处理PDF。我正在努力为我的桌子手动设置位置,也就是说,我希望两者都在中间,而不是靠近边缘。使用grid.arrange()公式时,将自动设置位置

此外,我想知道如何才能使脚注更偏左,甚至在表格“之前”

如何将布局矩阵()调整为该值

grid.arrange(table1, table)
请参阅简化代码:

pdf("mrcars_check.pdf",width = 15, height=10, bg = "white", onefile = TRUE, title = "ANALYSIS OF MoM CHANGES IN BUSA MORTGAGES")


table1 <- tableGrob((format(mtcars[1:2,], big.mark = ",", digits = NULL, decimal.mark = ".", nsmALL=0, scientific = FALSE)),rows = NULL)
title1 <- textGrob(paste0("Title"),gp=gpar(fontsize=16))
footnote1 <- textGrob(paste0("Footnote"),x=0, hjust=0,gp=gpar(fontface="italic",fontsize=14))

padding <- unit(2,"line")
table1 <- gtable_add_rows(table1, 
                          heights = grobHeight(title1) + padding,
                          pos = 0)
table1 <- gtable_add_rows(table1, 
                          heights = grobHeight(footnote1)+ padding)
table1 <- gtable_add_grob(table1, list(title1, footnote1),
                          t=c(1, nrow(table1)), l=c(1,2), 
                          r=ncol(table1))

### table 2
table <- tableGrob((format(mtcars[4:9,], big.mark = ",", digits = NULL, decimal.mark = ".", nsmALL=0, scientific = FALSE)),rows = NULL) 
title <- textGrob(paste0(" Title"),gp=gpar(fontsize=14))
footnote <- textGrob(paste0("
This is a footnote.This is a footnote.This is a footnote.This is a footnote.This is a footnote.This is a footnote.This is a footnote.This is a footnote.This is a footnote.This is a footnote.This is a footnote.
                            This is a footnote.This is a footnote.This is a footnote.This is a footnote.This is a footnote."),x=0, hjust=0,
                     gp=gpar(fontface="italic",fontsize=14))

padding <- unit(2,"line")
table <- gtable_add_rows(table, 
                         heights = grobHeight(title) + padding,
                         pos = 0)
table <- gtable_add_rows(table, 
                         heights = grobHeight(footnote)+ padding)
table <- gtable_add_grob(table, list(title, footnote),
                         t=c(1, nrow(table)), l=c(1,2), 
                         r=ncol(table), clip='off')

print(grid.arrange(table1, table))

dev.off()
pdf(“mrcars\u check.pdf”,宽度=15,高度=10,bg=“white”,onefile=TRUE,title=“分析BUSA抵押贷款的月环比变化”)

表1能否向我们展示一下
table1
table2
是如何构建的?你不需要显示真实的表格,只是一些类似的东西。这有用吗?它不可复制。您没有向我们展示您正在使用的软件包(我相信它们是
gridExtra
gtable
),更重要的是,我们没有您的
xxx
数据集。您好,希望现在一切顺利。谢谢如果添加
库(网格);图书馆(gtable);库(gridExtra)
开始时,它现在是可执行的。希望你能得到答案!