Learn R Programming

textutils (version 0.4-1)

toLatex.data.frame: Convert Data Frame to LaTeX

Description

Convert data frames to character vector in LaTeX markup.

Usage

# S3 method for data.frame
toLatex(object, row.names = FALSE,
        col.handlers = list(), class.handlers = list(),
        eol = "\\\\", ...)

Value

character

Arguments

object

a data.frame

row.names

include the row names as the first column

col.handlers

a list of named functions

class.handlers

a list of named functions

eol

character: the line ending; may be a vector of length greater than one

...

other arguments

Author

Enrico Schumann

Details

A method for toLatex that converts data frames into LaTeX markup. Any formatting to be applied must be specifed as a function and passed with col.handlers and class.handlers.

col.handlers take precedent over class.handlers.

See Also

Examples

Run this code
df <- data.frame(letter = letters[1:5],
                 number = runif(5),
                 stringsAsFactors = FALSE)
toLatex(df,
        col.handlers = list(letter = toupper),
        class.handlers = list(numeric = function(x) format(x, digits = 4)),
        eol = "\\[1ex]")
cat(toLatex(df,
            col.handlers = list(letter = toupper),
            class.handlers = list(numeric = function(x) format(x, digits = 4)),
            eol = "\\[1ex]"), sep = "\n")

Run the code above in your browser using DataLab