使用tableGrob左对齐不正确
当我创建一个带有左对齐字符串的tableGrob时,最终结果显示在末尾剪裁的字符串。 是虫子还是我错过了什么使用tableGrob左对齐不正确,r,gridextra,R,Gridextra,当我创建一个带有左对齐字符串的tableGrob时,最终结果显示在末尾剪裁的字符串。 是虫子还是我错过了什么 library(gridExtra) slices <- c(10, 12, 4, 16, 8) lbls <- c("US", "UK", "long string left justified but is clipped at the end", "Germany", "France") z <- data.frame(lbls,slices) grid.new
library(gridExtra)
slices <- c(10, 12, 4, 16, 8)
lbls <- c("US", "UK", "long string left justified but is clipped at the end", "Germany", "France")
z <- data.frame(lbls,slices)
grid.newpage()
grid.draw(tableGrob(z, core.just="left"))
库(gridExtra)
切片这是一只虫子;包作者显然不理解网格中的文本对齐
你可以这样修理它
textii <- function(d, gp=gpar(), name="row-label-",
just="center", parse=TRUE){
x <- switch(just, "center"=0.5, "right"=1, "left"=0)
parseglobal <- parse
function(ii, parse=parseglobal){
lab <- if(parse) parse(text=d[ii]) else d[ii]
textGrob(x=x, label=lab, just=just, gp=gp, name=paste(name, ii, sep=""))
}
}
assignInNamespace("textii", textii, "gridExtra")
grid.table(z, core.just="left")
textii运行良好+1!顺便说一句,很幽默!是我错了还是你是作者?:-)tableGrob
仍然是一个非常有用的工具,尽管有这些反对意见。我刚刚用“\n”和padding.h=unit(10,“mm”)
对它进行了测试,结果非常好。非常感谢,工作非常完美,真的是一个非常有用的包,非常棒。