%**************************************************************************\r
\documentclass{article}\r
\usepackage[a4paper,height=24cm]{geometry} % geometry first\r
+\usepackage{listings}\r
\usepackage{array}\r
\usepackage{booktabs}\r
\usepackage{longtable}\r
\newcommand\code[1]{\texttt{#1}}\r
\newcommand\pkg[1]{\textbf{#1}}\r
\setcounter{tocdepth}{2}\r
+\r
+\lstset{language=R,basicstyle=\ttfamily,\r
+ keywordstyle=\ttfamily,\r
+ emphstyle=\itshape,\r
+ escapeinside = ||,\r
+ lineskip=0pt}\r
+\r
\begin{document}\r
\r
\title{The \pkg{xtable} Gallery}\r
temp.table\r
@\r
\r
+\subsection{Mathematical arrays}\r
+\label{sec:mathematical-arrays}\r
+\r
+Mathematical arrays (as compared to data arrays) can be printed\r
+correctly by declaring the class as \code{xtableMatharray}.\r
+<<matharraydata>>=\r
+V <- matrix(c(1.140380e-03, 3.010497e-05, 7.334879e-05,\r
+ 3.010497e-05, 3.320683e-04, -5.284854e-05,\r
+ 7.334879e-05, -5.284854e-05, 3.520928e-04), nrow = 3)\r
+V\r
+class(V) <- c("xtableMatharray")\r
+class(V)\r
+xtbl <- print(xtable(V, display = rep("E", 4)))\r
+@ %def\r
+\r
+Then \code{xtbl} can be used in an expression such as\r
+$V=\left[\Sexpr{xtbl}\right]$, produced by\r
+\begin{lstlisting}\r
+V=\left[\Sexp||r{xtbl}\right]. \r
+\end{lstlisting}\r
+\r
+\r
+An alternative display can be created using the \texttt{digits}\r
+argument. If \code{xtbl} is defined instead according to\r
+\r
+<<altmatharray, results = 'hide'>>=\r
+xtbl <- print(xtable(V, digits = 6))\r
+@ %def \r
+then we get\\\r
+$V=\left[\Sexpr{paste(print(xtable(V, digits = 6)))}\right].$ \r
\newpage\r
\r
<<include=FALSE>>=\r
function(str) gsub("_", "\\_", str, fixed = TRUE))\r
@\r
\r
+\r
\newpage\r
\r
\subsection{Markup in tables}\r
print(xtable(money), sanitize.rownames.function = function(x) {x})\r
@\r
\r
+\r
+\r
\section{Format examples}\r
\subsection{Adding a centering environment}\r
<<results='asis'>>=\r
tli.table\r
@\r
\r
+\subsection{Minus signs}\r
+\label{sec:minus-signs}\r
+\r
+The standard print functions do not render minus signs properly. They\r
+are actually hyphens (-) rather than minus signs ($-$). True minus\r
+signs can be obtained using the \code{math.style.negative} argument.\r
+\r
+\p\r
+Here is the \LaTeX{} which is produced:\r
+\r
+<<>>=\r
+pr1 <- prcomp(USArrests)\r
+print(xtable(pr1), math.style.negative = TRUE)\r
+@ \r
+\r
+And here is the resulting table.\r
+<<results='asis'>>=\r
+print(xtable(pr1), math.style.negative = TRUE)\r
+@\r
+\r
+\r
\newpage\r
\r
\subsection{Suppress row/column names}\r