我有一个有3列的表,我正在使用grid.table生成一个pdf版本。我希望其中两列为粗体,另一列为纯文本。我还没有找到一个通用的解决方案,grid.table cran页面只显示如何编辑行或特定单元格的字体。
使用小样本数据集(由于敏感性):
> dput(Data)
structure(list(Location = structure(c(1L, 1L, 1L, 2L, 2L, 3L), .Label = c("A", "B", "C"), class = "factor"),
Subloc = structure(1:6, .Label = c("A1","A2", "A3", "B1", "B2", "C1"),
class = "factor"), Type = structure(c(3L,3L, 3L, 1L, 1L, 2L),
.Label = c("Alpha", "Beta", "Meta"),
class = "factor")),
class = "data.frame",
row.names = c(NA, -6L))
我的现有代码:
maxrow <- c(30);
npages <- ceiling(nrow(Data)/maxrow);
pdf(paste0("DATE.pdf"), height = 11, width = 10)
idx <- seq(1, maxrow)
grid.table(Data[idx, ], rows = NULL, theme = ttheme_minimal(core=list(fg_params=list(hjust=0, x=0.1, fontface = c("bold"))),
rowhead=list(fg_params=list(hjust=0, x=0)), colhead=list(fg_params=list(fontsize = 14, col="#660066", fontface="bold"))))
for (i in 2:npages){
grid.newpage();
if(i*maxrow <= nrow(Data)) {
idx <- seq(1+((i-1)*maxrow), i*maxrow)} else{
idx <- seq(1+((i-1)*maxrow), nrow(Data))}grid.table(Data[idx,], rows =NULL,theme = ttheme_minimal(core=list(fg_params=list(hjust=0, x=0.1)), rowhead=list(fg_params=list(hjust=0, x=0)),colhead=list(fg_params=list(fontsize = 14, col="#660066", fontface="bold"))))
}dev.off()
我想使位置和类型列(而不是列标题)中的数据为粗体。我已经设法在fg_params=列表包装器中将所有列内容加粗,但不知道如何指定要对其进行此处理的列。