当您包装一个字符串以适合一个单元格时,有没有办法调整 R 中 TableGrob 中的行距?
Is there a way to adjust the linespacing in a TableGrob in R, when you have wrapped a string to fit in a cell?
我正在尝试减少具有长字符串的单元格中的行距。
library(gridExtra)
Table <- data.frame(Model = c("Long names bla bla", "Long name bla bla 2"))
Table[,"Model"] <- sapply(Table[,"Model"] , function(x) paste(strwrap(x, width = 10), collapse="\n"))
grid.arrange(tableGrob(Table))
请在此处查看示例代码输出。
Linespacing looks about 1.5 pt I would like it to be 1 pt
get.gpar()$lineheight
# 1.2 default
mytheme <- ttheme_default(core=list(fg_params=list(lineheight=1)))
grid.newpage()
grid.draw(tableGrob(Table, theme = mytheme))
我正在尝试减少具有长字符串的单元格中的行距。
library(gridExtra)
Table <- data.frame(Model = c("Long names bla bla", "Long name bla bla 2"))
Table[,"Model"] <- sapply(Table[,"Model"] , function(x) paste(strwrap(x, width = 10), collapse="\n"))
grid.arrange(tableGrob(Table))
请在此处查看示例代码输出。 Linespacing looks about 1.5 pt I would like it to be 1 pt
get.gpar()$lineheight
# 1.2 default
mytheme <- ttheme_default(core=list(fg_params=list(lineheight=1)))
grid.newpage()
grid.draw(tableGrob(Table, theme = mytheme))