matrix2latex {matlib} | R Documentation |
Convert matrix to LaTeX equation
Description
This function provides a soft-wrapper to xtable::xtableMatharray()
with additional support for
fractions
output and brackets
.
Usage
matrix2latex(
x,
fractions = FALSE,
brackets = TRUE,
show.size = FALSE,
digits = NULL,
...
)
Arguments
x |
a matrix |
fractions |
logical; if |
brackets |
logical or a character in |
show.size |
logical; if |
digits |
Number of digits to display. If |
... |
additional arguments passed to |
Details
The code for brackets
matches some of the options from the AMS matrix LaTeX package:
\pmatrix{}
, \bmatrix{}
, \Bmatrix{}
, ... .
Author(s)
Phil Chalmers
Examples
A <- matrix(c(2, 1, -1,
-3, -1, 2,
-2, 1, 2), 3, 3, byrow=TRUE)
b <- c(8, -11, -3)
matrix2latex(cbind(A,b))
matrix2latex(cbind(A,b), digits = 0)
matrix2latex(cbind(A/2,b), fractions = TRUE)
matrix2latex(A, digits=0, brackets="p", show.size = TRUE)