Skip to contents

Make latex array

Usage

latexarray(
  M,
  left = "",
  right = "",
  env = "array",
  includenames = TRUE,
  align = NULL,
  lines = TRUE
)

Arguments

M

A matrix

left

left delimiter options: [(|

right

right delimiter options: ])|

env

Array environment

includenames

Include column and row names

align

Column alignment. For a three column matrix, alignment defaults to centering columns("ccc"). If there are row labels, the default would be "r|ccc" to right-align the row labels and separate them with vertical line.

lines

Include lines separating column and row names

Value

character string

Examples

M <- diag(3)
colnames(M) <- LETTERS[1:3]
rownames(M) <- LETTERS[1:3]
latexarray(M)
#> [1] "\\begin{array}{r|ccc}\n & A & B & C\\\\\n\\hline A & 1 & 0 & 0\\\\\nB & 0 & 1 & 0\\\\\nC & 0 & 0 & 1\n\\end{array}"