Skip to contents

Given a numeric matrix, a data.frame, a tibble or a data.table returns a basic LaTeX table write with table and tabular packages. Rownames and colnames are highlighted with bold.

Usage

tableToLatex(object, digits = 3, file = FALSE, double_space = FALSE)

Arguments

object

A numeric matrix, data.frame, tibble or data.table

digits

Number of decimals. Default = 3

file

If TRUE write file with object name in work directory. Default FALSE

double_space

If TRUE add empty columns to increase space between columns

Value

Text on terminal or on a file to copy in LaTeX environment

Examples

mat <- matrix(1:9, nrow = 3)
mat
#>      [,1] [,2] [,3]
#> [1,]    1    4    7
#> [2,]    2    5    8
#> [3,]    3    6    9

tableToLatex(mat)
#> \begin{table}[htbp] 
#> \centering 
#>  \begin{tabular}{ccc} 
#>  \textbf{ V1 } & \textbf{ V2 } & \textbf{ V3 } \\ 
#>  1.000 & 4.000 & 7.000 \\ 
#>  2.000 & 5.000 & 8.000 \\ 
#>  3.000 & 6.000 & 9.000 \\ 
#>  \end{tabular} 
#> \caption{} 
#> \label{} 
#> \end{table}