]> git.donarmstrong.com Git - xtable.git/commitdiff
Completed addition of function print.xtableMatharray.R including test code in tests...
authordscott <dscott@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Thu, 10 Dec 2015 11:34:19 +0000 (11:34 +0000)
committerdscott <dscott@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Thu, 10 Dec 2015 11:34:19 +0000 (11:34 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@75 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/NEWS
pkg/R/print.xtableMatharray.R
pkg/R/xtable.R
pkg/man/print.xtableMatharray.Rd
pkg/man/xtable.Rd
pkg/tests/test.matharray.R

index bd83d92bcbb400228d19921bd01ff5a79c27a749..a6025c4ae1db89cbb3d9d20b4f3fb45950256506 100644 (file)
--- a/pkg/NEWS
+++ b/pkg/NEWS
@@ -1,5 +1,7 @@
 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.
index 63515b81834645cce3493df7a76d59536437669d..5c8317538d41ce22842a46e126db45e8a4b72bd6 100644 (file)
@@ -1,5 +1,5 @@
 print.xtableMatharray <- function(x,
-           print.results = FALSE,
+           print.results = TRUE,
            format.args = getOption("xtable.format.args", NULL),
            scalebox = getOption("xtable.scalebox", NULL),
            comment = FALSE,
index 76a4be963ee125dd138f5dd1a8ea69447ec15c7d..e3c1e048b17788e61d70239c2739c8bd6d7becc7 100644 (file)
@@ -80,7 +80,7 @@ xtable.xtableMatharray <- function(x, caption = NULL, label = NULL,
                         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
index fc76f2e977ecf63381cdbe4a20090139852ca912..e725f938235aaa4fb0105cdf45a7a315b1408e3a 100644 (file)
@@ -7,7 +7,7 @@
 }\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
@@ -19,7 +19,7 @@
   \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
index cb33e88af9aaff4aece5853cd848e0db536d6a02..33bb8cd9a28173b03629cc558b252edcc291cd47 100644 (file)
@@ -7,6 +7,7 @@
 \alias{xtable.glm}
 \alias{xtable.lm}
 \alias{xtable.matrix}
+\alias{xtable.xtableMatharray}
 \alias{xtable.prcomp}
 \alias{xtable.coxph}
 \alias{xtable.summary.aov}
index fed6f85aa063a8a02b9c2ee3c19f15da20e2471f..3f51aa288281aa6c565ee5d027b2a8930f08f955 100644 (file)
@@ -2,39 +2,36 @@ require(xtable)
 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))