1

I'm trying to build a table using tableGrob in gridExtra and can't figure out how to set the column with. I am using ttheme_minimal(base_size = 25) to set the size of the text, but I can't seem to find a way in that function to se the column widths. Below is the full code that I'm using:

team_free_agents <- structure(list(Player = c("Adrian Amos", "Dean Lowry", "Marcedes Lewis", 
                                              "Allen Lazard", "Robert Tonyan", "Jarran Reed", "Randall Cobb", 
                                              "Rudy Ford", "Yosh Nijman", "Keisean Nixon", "Justin Hollins"
), Position = c("S", "IDL", "TE", "WR", "TE", "IDL", "WR", "S", 
                "LT", "CB", "EDGE"), Age = c(30, 29, 39, 28, 29, 31, 33, 29, 
                                             27, 26, 27), `Snap %` = c("94.6%", "46.7%", "41.2%", "78.9%", 
                                                                       "54%", "68.2%", "33.9%", "42.8%", "69.1%", "28%", "40.7%"), `Current APY` = c("$9,000,000", 
                                                                                                                                                     "$6,775,000", "$4,000,000", "$3,986,000", "$3,750,000", "$3,250,000", 
                                                                                                                                                     "$3,000,000", "$1,137,500", "$965,000", "$965,000", "$706,724"
                                                                       ), `Current Guarantees` = c("$12,000,000", "$6,000,000", "$2,100,000", 
                                                                                                   "$0", "$1,000,000", "$1,865,000", "$0", "$0", "$0", "$0", "$306,896"
                                                                       ), `2022 PFF Grade` = c(54.2, 59.3, 65.6, 69, 57.7, 61.9, 70.1, 
                                                                                               77.7, 63.1, 63.9, 54)), row.names = c(NA, -11L), class = c("tbl_df", 
                                                                                                                                                          "tbl", "data.frame"))
tt1 <- gridExtra::ttheme_minimal(base_size = 25)

fa_table <- gridExtra::tableGrob(team_free_agents,
                                 rows = NULL,
                                 theme = tt1)

cowplot::draw_grob(
  fa_table,
  width = 90
)

Any help with this would be appreciated!

Sam Hoppen
  • 355
  • 2
  • 9
  • 2
    Not sure of your expected plot, but oyu can change the cell widths by chaging the elements `fa_table$widths` e.g. `fa_table$widths <- rep(grid::unit(10, "cm"), length(fa_table$widths))` – user20650 Feb 04 '23 at 18:42
  • 2
    [*this*](https://stackoverflow.com/questions/33214671/merging-table-header-cells-using-tablegrob/33218463#33218463) *might* be relevant – user20650 Feb 04 '23 at 18:43

0 Answers0