When I create a tableGrob with left justified strings, the final result shows the strings clipped at the end. Is a bug or I missed something?
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"))
It's a bug; the package author clearly doesn't understand text justification in grid.
You can sort of fix it like so,
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")
and/or adjust the padding.h
parameter to give more space. Sigh, what a mess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With