adding rows or boldify single row.names with print.xtables – add something in between rows?

巧了我就是萌 提交于 2019-12-01 06:10:42
agstudy

For the hline part, see ?print.xtable.

hline.after: When 'type="latex"', a vector of numbers between -1 and '"nrow(x)"', inclusive, indicating the rows after which a horizontal line should appear

To embolden all you rows names:

bold.allrows <- function(x) {
  h <- paste('\\textbf{',x,'}', sep ='')
  h
}
print(xtable(yourTable), 
      sanitize.rownames.function =  bold.allrows)

To embolden some row names, you can add a " special markup" to those rows, e.g. BOLD:

bold.somerows <- 
        function(x) gsub('BOLD(.*)',paste('\\\\textbf{\\1','}'),x)

print(xtable(yourTable), 
      sanitize.rownames.function =  bold.somerows)

e.g:

require(xtable)
hh <- head(mtcars)[ , c(1:5)]
## I want to bold 1 and 3 rows 
rownames(hh)[c(1, 3)] <- paste('BOLD', rownames(hh)[c(1, 3)])
print(xtable(hh), sanitize.rownames.function =  bold.somerows)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!