Learn R Programming

cwhmisc (version 4.0)

tex.table: Convert a data matrix into LaTeX code.

Description

These functions convert a data matrix into latex{{LaTeX}. } tex.table(dm, bare = FALSE, prec = if (bare) "NA" else 2, rnames = if (bare) "-1" else dimnames(dm)[[1]], cnames = if (bare) "-1" else dimnames(dm)[[2]], caption = NULL, label = NULL, tpos = "b", stretch = NULL, adjust = "r", file = NULL) tex.tab0(dm, prec = 2, rnames = NULL, cnames = NULL, caption = NULL, label = NULL, tpos = "b", stretch = NULL, adjust = "r", file = NULL) dm{data matrix} bare{TRUE: prec,rnames,cnames will get useful defaults, FALSE: set these parameters yourself} prec{precision of rounding within the LATEX table, if NA, then no transformation to numeric is done} rnames{row names} cnames{column names} caption{caption for LATEX table, default: no caption} label{LATEX label for the table, default: no lable} tpos{position of captions: "a" for above table, "b" for belowbelow table} stretch{optional vector with two entries, giving the baselinestretch for the caption (stretch[1]) and the colums of the table (stretch[2]); default: no adjustment of baselinestretch} adjust{adjusts the columns of the LATEX table, default: "r" (right), also possible: "l" (left) and "c" (centre) or user defined: "adjust=c("l","c","r",...)" yields {l|cr...}} file{output file, default: printout in console} These functions are called for their side effect to write to a file. tex.table{generate complete minimal Tex-able .tex file, including 'footnotesize'} tex.tab0{same as 'tex.table' but without 'footnotesize'} m <- matrix(rnorm(100),nrow=10,ncol=10,dimnames=list(LETTERS[1:10],colnames=letters[1:10])) tex.table(m,file="tex.table.tex") # tabular{r|rrrrrrrrrr} # # & a & b & c & d & e & f & g & h & i & j\ # A & -0.63 & 1.51 & 0.92 & 1.36 & -0.16 & 0.40 & 2.40 & 0.48 & -0.57 & -0.54\ # B & 0.18 & 0.39 & 0.78 & -0.10 & -0.25 & -0.61 & -0.04 & -0.71 & -0.14 & 1.21\ # ... [object Object] interface

Arguments