1.8-1 (NOT YET SUBMITTED TO CRAN)
-
+ * added function print.xtableMatharray to enable easy creation of
+ LaTeX code to enable an array to be included in a document.
+
1.8-0
* autoformat, xalign, xdigits, xdisplay from Arni Magnusson, added
along with help file. Feature request #5686.
print.xtableMatharray <- function(x,
- print.results = FALSE,
+ print.results = TRUE,
format.args = getOption("xtable.format.args", NULL),
scalebox = getOption("xtable.scalebox", NULL),
comment = FALSE,
digits = digits, display = display, auto = auto,
...)
class(xtbl) <- c("xtableMatharray","xtable","data.frame")
- return(xtbl)
+ return(xtbl)
}
### table objects (of 1 or 2 dimensions) by Guido Gay, 9 Feb 2007
}\r
\usage{\r
\method{print}{xtableMatharray}(x,\r
- print.results = FALSE,\r
+ print.results = TRUE,\r
format.args = getOption("xtable.format.args", NULL),\r
scalebox = getOption("xtable.scalebox", NULL),\r
comment = FALSE,\r
\item{print.results}{If \code{TRUE}, the generated table is printed to\r
standard output. Set this to \code{FALSE} if you will just be using\r
the character vector that is returned invisibly.\r
- Default value is \code{FALSE}.} \r
+ Default value is \code{TRUE}.}\r
\item{format.args}{List of arguments for the \code{formatC} function.\r
For example, standard German number separators can be specified as\r
\code{format.args=list(big.mark = "'", decimal.mark = ",")}. The\r
\item{...}{Additional arguments. (Currently ignored.) }\r
}\r
\details{\r
- Here are some details.\r
+ This command prints an array of numbers which may be included in a\r
+ mathematical expression in a LaTeX document created using \pkg{Sweave}\r
+ or \pkg{knitr}. Internally it calls \code{print.data.frame} but with\r
+ special values for the arguments, namely that the tabular environment\r
+ is \code{array}, row names and column names are not included, and there\r
+ are no horizontal lines. Note that the default values for the arguments\r
+ \code{comment} and \code{timestamp} are different to the default values\r
+ for \code{print.xtable}, the justification being that comments would\r
+ make the resulting LaTeX harder to read.\r
}\r
\value{\r
A character vector containing the LaTeX code for incorporating an\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
+### Simple test of print.xtableMatharray\r
+print.xtableMatharray(xtable(V, display = rep("E", 4)))\r
+\r
class(V) <- c("xtableMatharray")\r
class(V)\r
\r
+### Test without any additional arguments\r
mth <- xtable(V)\r
str(mth)\r
-mth\r
+print(mth)\r
+\r
+### Test with arguments to xtable\r
+mth <- xtable(V, display = rep("E", 4))\r
+str(mth)\r
+print(mth)\r
+\r
+mth <- xtable(V, digits = 6)\r
+str(mth)\r
+print(mth)\r
+\r
+### Test with additional print.xtableMatharray arguments\r
+mth <- xtable(V, digits = 6)\r
+str(mth)\r
+print(mth, format.args = list(decimal.mark = ","))\r
+print(mth, scalebox = 0.5)\r
+print(mth, comment = TRUE)\r
+print(mth, timestamp = "2000-01-01")\r
+print(mth, comment = TRUE, timestamp = "2000-01-01")\r
}\r
\r
\keyword{print}\r
\alias{xtable.glm}
\alias{xtable.lm}
\alias{xtable.matrix}
+\alias{xtable.xtableMatharray}
\alias{xtable.prcomp}
\alias{xtable.coxph}
\alias{xtable.summary.aov}
V <- matrix(c(1.140380e-03, 3.010497e-05, 7.334879e-05,
3.010497e-05, 3.320683e-04, -5.284854e-05,
7.334879e-05, -5.284854e-05, 3.520928e-04), nrow = 3)
-V
+### Simple test of print.xtableMatharray
+print.xtableMatharray(xtable(V, display = rep("E", 4)))
+
class(V) <- c("xtableMatharray")
class(V)
+### Test without any additional arguments
mth <- xtable(V)
str(mth)
-mth
-
-tbl <- xtable(V, display = rep("E", 4))
-str(tbl)
-tbl
+print(mth)
-V <- matrix(c(1.140380e-03, 3.010497e-05, 7.334879e-05,
- 3.010497e-05, 3.320683e-04, -5.284854e-05,
- 7.334879e-05, -5.284854e-05, 3.520928e-04), nrow = 3)
-V
+### Test with arguments to xtable
mth <- xtable(V, display = rep("E", 4))
-class(mth)
-mth
-class(mth) <- c("xtableMatharray")
-mth
+str(mth)
print(mth)
-print.xtableMatharray(xtable(V, display = rep("E", 4)))
-class(mth) <- c("xtableMatharray")
-mth
-V <- matrix(c(1.140380e-03, 3.010497e-05, 7.334879e-05,
- 3.010497e-05, 3.320683e-04, -5.284854e-05,
- 7.334879e-05, -5.284854e-05, 3.520928e-04), nrow = 3)
-V
+mth <- xtable(V, digits = 6)
+str(mth)
+print(mth)
+
+### Test with additional print.xtableMatharray arguments
+mth <- xtable(V, digits = 6)
+str(mth)
+print(mth, format.args = list(decimal.mark = ","))
+print(mth, scalebox = 0.5)
+print(mth, comment = TRUE)
+print(mth, timestamp = "2000-01-01")
+print(mth, comment = TRUE, timestamp = "2000-01-01")
+
+
+
-print.xtableMatharray(xtable(V),
- format.args = list(display = rep("E", 4)))
-print.xtableMatharray(xtable(V),
- format.args = list(digits = 6))