I try to use print.xtable
add.to.row
to get table formatted like this:
sports
share of ballers 22.3
sh
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)