Home > database >  Adjusting distance from labels to table in grid.arrange in R
Adjusting distance from labels to table in grid.arrange in R

Time:10-24

I cannot find how to adjust distance from labels to table in grid.arrange:

distances_lsit = c(25,50,75,100) 
category_lsit = 0:5 
damage_table = matrix(NA, nrow=length(distances_lsit), ncol=length(category_lsit))
damage_table[1,] = c(10,25,50,75,100,100)
damage_table[2,] = c(5,10,25,50,75,100)
damage_table[3,] = c(2.5,5,10,25,50,75)
damage_table[4,] = c(0,2.5,5,10,25,50)
rownames(damage_table) = distances_lsit
colnames(damage_table) = category_lsit
table_scale = tableGrob(damage_table)

grid.arrange(table_scale, top = "Label 1", left = "Label 2")

which produces table as follows: enter image description here

Is there anyway to glue it to the table? Thank you in advance for your help.

CodePudding user response:

You should play with next parameters for finding your best location

  • heights;
  • widths;
  • textGrob.

For example, this:

grid.arrange(table_scale, top = textGrob("Really looks \n better now?", x = 0, hjust = -1), left = "I'm near,\n my man", heights = c(2,1), widths = c(1,1.5))

show to you this:

enter image description here

  • Related