R tableGrob change format of row

前端 未结 3 1826
感动是毒
感动是毒 2021-01-03 13:31

I have some relatively simple code to create a table for printing to a PDF:

library(gridExtra)
df <- head(iris)
tableGrob(df, gp = gpar(fontsize = 8), row         


        
3条回答
  •  独厮守ぢ
    2021-01-03 14:06

    One option is to create a new table, and merge the two together,

    g1 <- tableGrob(iris[1:4, 1:3], rows=NULL)
    g2 <- tableGrob(iris[1, 1:3], rows=NULL, # can't have empty content
                    cols=as.character(iris[4, 1:3])) # use 4th row as header
    
    grid.newpage()
    g <- rbind(g1[-nrow(g1), ], g2[1,])
    grid.draw(g)
    

提交回复
热议问题