Can anyone solve why the cutoff of row names occurs for me? It is independent of the length of the string wrap. Specifying row.just = "center" does not cut off the row names.
x <- data.frame(row.names=paste("Very very name goes in here somewhere yep it is a looooonnngggg name! phew that was a long name",1:10))
# string wrap long names
rownames(x) <- sapply(lapply(rownames(x), strwrap, width=40), paste, collapse="\n")
# data frame
x[,1] <- 1:10
x[,2] <- sample(1:100,10)
x[,3] <- sample(LETTERS[1:26],10)
colnames(x) <- c("Value 1", "Value 2", "Label")
# create table
main_table <- tableGrob(x,cols = colnames(x), show.colnames = TRUE, row.just = "left")
# display table (is there another way to display?
grid.arrange(main_table)
Gives me this (sorry about the zoom)
whereas specifying "center" gives me this
main_table <- tableGrob(x,cols = colnames(x), show.colnames = TRUE, row.just = "center")
grid.arrange(main_table)
Any ideas?
p.s. I'm not sure why the images are like that, when I click 'zoom' in the plotting window they are full tables, but saving/exporting only saves the zoomed-in version...
i'm guessing it's because the available width is calculated from the string width, but justification shifts the text to the right. hjust/x interactions have always confused me in grid. You can "fix" it with,
but that's not a very good solution I'm afraid.