data.frame.to.latex.table.string: Output the contents of a numeric matrix or dataframe into...

View source: R/data.frame.to.latex.table.string.R

data.frame.to.latex.table.stringR Documentation

Output the contents of a numeric matrix or dataframe into LaTeX type table notation string

Description

Output the contents of a numeric matrix or dataframe into LaTeX type table notation string

Usage

data.frame.to.latex.table.string(
  dframe,
  topLeft = "",
  header = TRUE,
  cellFormat = function(i, j, cell) {
     return(cell)
 }
)

Arguments

dframe

A data.frame or matrix

topLeft

A string that will fill the top left corner (first cell of the first row) of the table

header

A boolean toggle. If true a full latex table with begintable etc is created, if false only cells are converted.

cellFormat

A function that will convert the cell content to a latex compatible string. The function has to accept three arguments, row, column and cell value and has to return a string. It is applied to the cells (i,j > 0) and to the margins (i,j = 0) including topLeft which sits at (0,0).

Value

A vector of strings where each entry is one line of latex code.

Examples

n <- 3
m <- 6
M1 <- matrix(1:(n*m),n,m)
rownames(M1) <- 1:n
colnames(M1) <- 1:m
S1 <- data.frame.to.latex.table.string(M1,topLeft="TL")

KlausHerrmann/khermisc documentation built on May 6, 2023, 7:08 p.m.