dftoLaTeX {vtable} | R Documentation |
Data Frame to LaTeX Function
Description
This function takes a data frame or matrix with column names and outputs a lightly-formatted LaTeX table version of that data frame.
Usage
dftoLaTeX(
data,
file = NA,
fit.page = NA,
frag = TRUE,
title = NA,
note = NA,
note.align = "l",
anchor = NA,
align = NA,
row.names = FALSE,
no.escape = NA
)
Arguments
data |
Data set; accepts any format with column names. |
file |
Saves the completed table to LaTeX with this filepath. |
fit.page |
uses a LaTeX resizebox to force the table to a certain width. Often |
frag |
Set to TRUE to produce only the LaTeX table itself, or FALSE to produce a fully buildable LaTeX. Defaults to TRUE. |
title |
Character variable with the title of the table. |
note |
Table note to go after the last row of the table. |
note.align |
Set the alignment for the multi-column table note. Usually "l", but if you have a long note you might want to set it with "p" |
anchor |
Character variable to be used to set a label tag for the table. |
align |
Character variable with standard LaTeX formatting for alignment, for example |
row.names |
Flag determining whether or not the row names should be included in the table. Defaults to |
no.escape |
Vector of column indices for which special characters should not be escaped (perhaps they include markup text of their own). |
Details
This function is designed to feed LaTeX versions of variable tables to vtable()
, sumtable()
, and labeltable()
.
Multi-column cells are supported. Wrap the cell's contents in a multicolumn
tag as normal, and then fill in any cells that need to be deleted to make room for the multi-column cell with "DELETECELL". Or use the MULTICOL syntax of dftoHTML
, that works too.
If the first column and row begins with the text "HEADERROW", then the first row will be put above the column names.
Examples
df <- data.frame(var1 = 1:4,var2=5:8,var3=c('A','B','C','D'),
var4=as.factor(c('A','B','C','C')),var5=c(TRUE,TRUE,FALSE,FALSE))
dftoLaTeX(df, align = 'ccccc')