A very useful function to create a LaTeX table from a matrix. Rounds numeric entries and also replaces small numbers with standard index form equivalents.
latextable(
x,
digits = 3,
scientific = -3,
colnames = NULL,
rownames = NULL,
caption = NULL,
narep = " ",
laststr = "",
intable = TRUE,
manualalign = NULL,
file = "",
...
)
prints the LaTeX table to screen, so it can be copied into reports
a matrix, or object that can be coerced to a matrix. x can include mixed character and numeric entries.
see help file for format
see help file for format
optional column names set to NULL (default) to automatically use column names of x. NOTE! if rownames is not NULL present, colnames must include an entry for the rownames i.e. it should be a vector of length the number of columns of x plus 1.
optional row names set to NULL (default) to automatically use row names of x
optional caption, not normally used
string giving replacement for NA entries in the matrix
string to write at end, eg note the double backslash!!
output in a table environment?
manual align string e.g. 'ccc' or 'l|ccc'
connection to write to, default is '' which writes to the console; see ?write for further details
additional arguments passed to format
To get a backslash to appear, use a double backslash
Just copy and paste the results into your LaTeX document.
latextable(as.data.frame(matrix(1:4,2,2)))
Run the code above in your browser using DataLab