简体   繁体   中英

Changing Header Row position in grid.table in R

I have the following code that I'm using to create a table using grid.table from the gridExtra package.

require(tidyverse)
require(gridExtra)

df<-data.frame(x=letters[1:13],y=1:13)
grid.table(df,rows=NULL)

Which generates the following table.

df 作为 grid.table 生成的图像

Is there any way to have the header row of the resulting table in the bottom most row of the table that grid.table returns? That's to say am being the on top of x and 1-13 being on top of y.

you can split and recombine the gtable,

tg = tableGrob(df,rows=NULL)
grid::grid.draw(rbind(tg[2:nrow(tg),], tg[1,]))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM