]> git.donarmstrong.com Git - xtable.git/commitdiff
Completed package improvements notably xtableList and xtableFtable functions
authordscott <dscott@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Fri, 29 Jan 2016 01:59:13 +0000 (01:59 +0000)
committerdscott <dscott@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Fri, 29 Jan 2016 01:59:13 +0000 (01:59 +0000)
and print methods

git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@105 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/NAMESPACE
pkg/NEWS
pkg/R/xtableFtable.R
pkg/man/xtableFtable.Rd
pkg/vignettes/xtableGallery.Rnw

index 9daba6af9ee7062a489217c551de2e593b46ff77..c912d904e1256f5cc3aa40c1baa92fb34054e407 100644 (file)
@@ -10,8 +10,7 @@ export("caption<-", "caption", "label", "label<-",
        "xtableFtable", "print.xtableFtable",
        "toLatex.xtable",
        "autoformat", "xalign", "xdigits", "xdisplay",
-       "sanitize", "sanitize.numbers", "sanitize.final", "as.is", "as.math",
-       "format.ftable")
+       "sanitize", "sanitize.numbers", "sanitize.final", "as.is", "as.math")
 
 S3method("print", "xtable")
 S3method("print", "xtableMatharray")
@@ -30,8 +29,6 @@ S3method("digits<-", "xtable")
 S3method("display<-", "xtable")
 S3method("display", "xtable")
 
-S3method("format", "ftable")
-
 S3method("xtable", "data.frame")
 S3method("xtable", "matrix")
 S3method("xtable", "table")
index 057abe082731446c443db419747e2661c9448a0c..9c2291e186f77db038e3306a36ec4bdca7618e1a 100644 (file)
--- a/pkg/NEWS
+++ b/pkg/NEWS
@@ -32,7 +32,7 @@
     xtableList and print.xtableList; and 'The Other Packages Gallery'
     to illustrate methods for classes of objects from other packages.
 
-1.8-0
+1.8-0 (2015-11-02)
   * autoformat, xalign, xdigits, xdisplay from Arni Magnusson, added
     along with help file. Feature request #5686.
   * New argument 'auto' in xtable(), to call xalign, xdigits, and
index dafb6f0e72ebe116d292703fa3c2032328b744a5..72964d86d9e75da88aba3497c8fd531538098792 100644 (file)
@@ -97,7 +97,7 @@ print.xtableFtable <- function(x,
   timestamp = getOption("xtable.timestamp", date()),
   ...) {
   if (type == "latex"){
-
+    ## extract the information in the attributes
     caption <- attr(x, "ftableCaption")
     label <- attr(x, "ftableLabel")
     align <- attr(x, "ftableAlign")
@@ -110,15 +110,14 @@ print.xtableFtable <- function(x,
     nCharCols <- attr(x, "nChars")[2]
     nRowVars <- length(attr(x, "row.vars"))
     nColVars <- length(attr(x, "col.vars"))
-    fmtFtbl <- format.ftable(x, quote = quote, digits = digits,
-                             method = method, lsep = lsep)
+    
+    ## change class so format method will find format.ftable
+    ## even though format.ftable is not exported from 'stats'
+    class(x) <- "ftable"
+    fmtFtbl <- format(x, quote = quote, digits = digits,
+                      method = method, lsep = lsep)
     attr(fmtFtbl, "caption") <- caption
     attr(fmtFtbl, "label") <- label
-    ## if method is "compact", rotate both if either requested
-    ## if (method == "compact"){
-    ##   if (rotate.rownames) rotate.colnames <- TRUE
-    ##   if (rotate.colnames) rotate.rownames <- TRUE
-    ## }
 
     ## sanitization is possible for row names and/or column names
     ## row names
@@ -187,3 +186,12 @@ print.xtableFtable <- function(x,
   }
 }
 
+## format.xtableFtable <- function(x, quote = TRUE, digits = getOption("digits"),
+##                                 method = c("non.compact", "row.compact",
+##                                            "col.compact", "compact"),
+##                                 lsep = " | ", ...){
+##   class(x) <- "ftable"
+  
+##   format(x, quote = quote, digits = digits,
+##          method = method, lsep = lsep, ...)
+## }
index 5d6b2dc9d120d65ffcd838b99bf68fd386787368..2e743b1a25906c0954a0c4dcaf6e9073445706ad 100644 (file)
@@ -274,9 +274,12 @@ xtableFtable(x, caption = NULL, label = NULL,
 
     \code{print.xtableFtable} uses the attributes attached to an object
     of class \code{c("xtableFtable", "ftable")} to create a suitable
-    character matrix object for subsequent printing via a call to
-    \code{stats:::format.ftable}. This matrix object is then printed via
-    a call to \code{print.xtable}.
+    character matrix object for subsequent printing. Formatting is
+    carried out by changing the class of the \code{c("xtableFtable",
+    "ftable")} to \code{"ftable"} then using the generic \code{format}
+    to invoke \code{format.ftable}, from the \pkg{stats} package. The
+    matrix object produced is then printed via a call to
+    \code{print.xtable}.
 
     Note that at present there is no code for \code{type = "html"}.
 }
index bb41fab3c3c7768a08fd3509ec81e8c9eaa2c3c5..c618d491a4d77fc84f946612af9c14efcdb7e621 100644 (file)
@@ -263,6 +263,7 @@ useful for formatting tables in a sensible way. Consider the output
 produced by the default formatting.\r
 \r
 <<results='asis'>>=\r
+data(mtcars)\r
 dat <- mtcars[1:3, 1:6]\r
 x <- xtable(dat)\r
 x\r