Learn R Programming

lazyWeave (version 2.2.0)

lazy.matrix: Convert Matrix to LaTeX Table

Description

An example of using lazyWeave to produce tables.

Usage

lazy.matrix(x, align="center", justify="center", rcol=NULL, usecol="lightgray",
            caption=NULL, footnote=NULL, placement="h", translate=TRUE, ...)

Arguments

x
A matrix. Other objects are coerced to matrices.
align
Character vector or string giving the alignment for each column of the table. Options are "left", "center", "right".
justify
Character string giving the alignment for the table on the page. Options are "left", "center", "right".
rcol
A vector giving the rows of x to be colored.
usecol
A character string or vector denoting the color of the rows in rcol.
caption
Caption for the table. This is printed above the table.
footnote
Additional footnotes for the table. These are printed below the table.
placement
Controls the placement of the figure. Options are "ht", "t", "b", "p", "H" and can be supplemented with "!". See "Details" for more explanation. These apply only to LaTeX.
translate
Toggles if inputs in x should be passed through latexTranslate. This should be set to FALSE if writing custom code.
...
Additional arguments to be passed to lazy.table

Details

The output for lazy.matrix is highly inflexible compared to lazy.table. It is an example of how to build a reproducible table with a certain formatting style that may be used again and again for consistency. Row names are always left justified. This cannot be changed. placement options are used as follows: ll{ ht Place the float here, i.e., approximately at the same point it occurs t Position at the top of the page b Position at the bottom of the page p Put on a special page for floats only H Places the float at precisely the location in the LaTeX code. Requires the float package } The "!" may be used after any of these in order to override LaTeX float rules and force your selection. More can be learned by reading about floats in a LaTeX manual.

Examples

Run this code
lazy.write(
  lazy.file.start(),
  lazy.text("The mtcars dataset describes a number of vehicles.  
      Let's take a look at the data"),
  lazy.matrix(mtcars, rcol=(1:nrow(mtcars))[c(FALSE, TRUE)]),
  lazy.file.end(),
  OutFile="Example 1.tex")
  
unlink("Example 1.tex")

Run the code above in your browser using DataLab