matrix2latex | R Documentation |
(This function has been deprecated; see latexMatrix
instead).
This function provides a soft-wrapper to xtable::xtableMatharray()
with additional support for
fractions
output and brackets
.
matrix2latex(
x,
fractions = FALSE,
brackets = TRUE,
show.size = FALSE,
digits = NULL,
print = TRUE,
...
)
x |
a numeric or character matrix. If the latter a numeric-based arguments will be ignored |
fractions |
logical; if |
brackets |
logical or a character in |
show.size |
logical; if |
digits |
Number of digits to display. If |
print |
logical; print the LaTeX code for the matrix on the console?; default: |
... |
additional arguments passed to |
The code for brackets
matches some of the options from the AMS matrix LaTeX package:
\pmatrix{}
, \bmatrix{}
, \Bmatrix{}
, ... .
Phil Chalmers
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)
# character matrices
A <- matrix(paste0('a_', 1:9), 3, 3)
matrix2latex(cbind(A,b))
b <- paste0("\\beta_", 1:3)
matrix2latex(cbind(A,b))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.