print_2heading_xtable: Print LaTeX tables with headings over two lines

Description Usage Arguments Value Author(s) Examples

Description

Print LaTeX tables with headings over two lines

Usage

1
2
3
print_2heading_xtable(.data, separator = "__", xtable.align = NULL,
  booktabs = TRUE, heading_command = "\\textbf",
  xtable.dots = NULL, ...)

Arguments

.data

A data frame with at least some of the column names having a separator.

separator

A regular expression that splits the top and bottom rows. If the separator is not found in the names of .data, the function returns an error (saying you should probably just use print.xtable())

xtable.align

Passed to xtable: Character vector of length equal to the number of columns of the resulting table, indicating the alignment of the corresponding columns.

booktabs

Should the tabular environment produced use booktabs? Set to TRUE for (my) convenience. This will cause an error if \usepackage{booktabs} has not been called in LaTeX.

heading_command

A (simple) LaTeX control sequence (properly escaped) to apply to each heading names.

xtable.dots

Arguments passed to xtable::xtable. Providing both xtable.dots and xtable.align is an error.

...

Arguments passed to print.xtable. You cannot pass add.to.row, include.rownames, or include.colnames as we make use of these options in this function.

Value

Output intended for LaTeX. A table produced using xtable where groups of column names are put in the top row.

Author(s)

Hugh Parsonage

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
example_df <- 
data.frame(yr = 2001:2005, 
          Revenue__foo = 1:5, 
          Revenue__bar = 11:15, 
          Revenue__baz = 21:25, 
          ordinary = 1:5,
          Expense__foo = 1:5,
          Expense__bar = 11:15, 
          Expense__baz = 21:25, 
          Last__foo = 1:5, 
          Last__baz = 2:6,
          last = 101:105)
print_2heading_xtable(example_df, separator = "__")
print_2heading_xtable(example_df, separator = "__", xtable.dots = list(caption = "My caption"))

HughParsonage/grattanCharts documentation built on May 8, 2019, 10:52 a.m.