]> git.donarmstrong.com Git - xtable.git/commitdiff
Added man/xtableMatharray.Rd. Fixed data commands in OtherPackagesGallery.Rnw
authordscott <dscott@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Tue, 12 Jan 2016 10:41:43 +0000 (10:41 +0000)
committerdscott <dscott@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Tue, 12 Jan 2016 10:41:43 +0000 (10:41 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@91 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/DESCRIPTION
pkg/R/sanitize.R
pkg/man/xtable-internal.Rd
pkg/man/xtableMatharray.Rd [new file with mode: 0644]
pkg/vignettes/OtherPackagesGallery.Rnw

index 098d922b862d12f503ea486c2290c32188d4a0e0..eabc9e23a7b089e1311165ae4c5fc0f358ee14a8 100644 (file)
@@ -5,7 +5,7 @@ Title: Export Tables to LaTeX or HTML
 Author: David B. Dahl <dahl@stat.byu.edu>
 Maintainer: David Scott <d.scott@auckland.ac.nz>
 Imports: stats, utils
-Suggests: knitr, lsmeans, spdep, splm, sphet
+Suggests: knitr, lsmeans, spdep, splm, sphet, plm
 VignetteBuilder: knitr
 Description: Coerce data to LaTeX and HTML tables.
 URL: http://xtable.r-forge.r-project.org/
index 18c6619e19e1e5af6099a091f7d39169f6c28ed4..c31a660f7fd8bcc84191d53288a8902536744116 100644 (file)
@@ -56,7 +56,7 @@ sanitize.numbers <- function(str, type,
       } else if (math.style.exponents == "UTF8" ||
                  math.style.exponents == "UTF-8") {
         for(i in 1:length(str)) {
-          ## this code turns 1e5 into 1×10⁵x
+          ## this code turns 1e5 into a UTF-8 representation of 1\times10^5
           if (all(grepl("^\\$?(-?)\\$?([0-9.]+)[eE]\\$?(-?)\\+?\\$?0*(\\d+)$",
                         result[i]))) {
             temp <- strsplit(result[i],"eE",result[i])
index 1e0bd4dec7d1b6e7c82d242ef2306c16ba4befd5..671ec830ad171fd92f0179b992989331bc983d78 100644 (file)
@@ -1,5 +1,4 @@
 \name{xtable-internal}\r
-\alias{xtableMatharray}\r
 \alias{xtableList}\r
 \alias{print.xtableList}\r
 \alias{xtableLSMeans}\r
diff --git a/pkg/man/xtableMatharray.Rd b/pkg/man/xtableMatharray.Rd
new file mode 100644 (file)
index 0000000..c050411
--- /dev/null
@@ -0,0 +1,105 @@
+\name{xtableMatharray}\r
+\alias{xtableMatharray}\r
+\r
+\title{\r
+ Create LaTeX Mathematical Array\r
+}\r
+\description{\r
+  Convert an array of numbers or mathematical expressions into an\r
+ \code{xtableMatharray} object so it can be printed. A convenience\r
+ function to enable the printing of arrays in mathematical expressions\r
+ in LaTeX\r
+}\r
+\usage{\r
+xtableMatharray(x, caption = NULL, label = NULL, align = NULL,\r
+                digits = NULL, display = NULL, auto = FALSE, ...)\r
+}\r
+\arguments{\r
+  \item{x}{A numeric or character matrix.}\r
+  \item{caption}{Character vector of length 1 or 2 containing the\r
+    table's caption or title.  If length is 2, the second item is the\r
+    "short caption" used when LaTeX generates a "List of Tables". Set to\r
+    \code{NULL} to suppress the caption.  Default value is \code{NULL}.\r
+    Included here only for consistency with \code{xtable} methods. Not\r
+    expected to be of use.}\r
+  \item{label}{Character vector of length 1 containing the LaTeX\r
+    label. Set to \code{NULL} to suppress the label.\r
+    Default value is \code{NULL}. }\r
+  \item{align}{Character vector of length equal to the number of columns\r
+    of the resulting table, indicating the alignment of the corresponding\r
+    columns.  Also, \code{"|"} may be used to produce vertical lines\r
+    between columns in LaTeX tables, but these are effectively ignored\r
+    when considering the required length of the supplied vector.  If a\r
+    character vector of length one is supplied, it is split as\r
+    \code{strsplit(align, "")[[1]]} before processing. Since the row\r
+    names are printed in the first column, the length of \code{align} is\r
+    one greater than \code{ncol(x)} if \code{x} is a\r
+    \code{data.frame}. Use \code{"l"}, \code{"r"}, and \code{"c"} to\r
+    denote left, right, and center alignment, respectively.  Use\r
+    \code{"p{3cm}"} etc. for a LaTeX column of the specified width. For\r
+    HTML output the \code{"p"} alignment is interpreted as \code{"l"},\r
+    ignoring the width request. Default depends on the class of\r
+    \code{x}. }\r
+  \item{digits}{Numeric vector of length equal to one (in which case it\r
+    will be replicated as necessary) or to the number of columns of the\r
+    resulting table \bold{or} matrix of the same size as the resulting\r
+    table, indicating the number of digits to display in the\r
+    corresponding columns. Since the row names are printed in the first\r
+    column, the length of the vector \code{digits} or the number of\r
+    columns of the matrix \code{digits} is one greater than\r
+    \code{ncol(x)} if \code{x} is a \code{data.frame}. Default depends\r
+    on the class of \code{x}. If values of \code{digits} are negative,\r
+    the corresponding values of \code{x} are displayed in scientific\r
+    format with \code{abs(digits)} digits.}\r
+  \item{display}{\r
+    Character vector of length equal to the number of columns of the\r
+    resulting table, indicating the format for the corresponding columns.\r
+    Since the row names are printed in the first column, the length of\r
+    \code{display} is one greater than \code{ncol(x)} if \code{x} is a\r
+    \code{data.frame}.  These values are passed to the \code{formatC}\r
+    function.  Use \code{"d"} (for integers), \code{"f"}, \code{"e"},\r
+    \code{"E"}, \code{"g"}, \code{"G"}, \code{"fg"} (for reals), or\r
+    \code{"s"} (for strings).  \code{"f"} gives numbers in the usual\r
+    \code{xxx.xxx} format; \code{"e"} and \code{"E"} give\r
+    \code{n.ddde+nn} or \code{n.dddE+nn} (scientific format); \code{"g"}\r
+    and \code{"G"} put \code{x[i]} into scientific format only if it\r
+    saves space to do so.  \code{"fg"} uses fixed format as \code{"f"},\r
+    but \code{digits} as number of \emph{significant} digits.  Note that\r
+    this can lead to quite long result strings.  Default depends on the\r
+    class of \code{x}.}\r
+  \item{auto}{\r
+    Logical, indicating whether to apply automatic format when no value\r
+    is passed to \code{align}, \code{digits}, or \code{display}. This\r
+    \sQuote{autoformat} (based on \code{xalign}, \code{xdigits}, and\r
+    \code{xdisplay}) can be useful to quickly format a typical\r
+    \code{matrix} or \code{data.frame}. Default value is \code{FALSE}.}\r
+  \item{...}{Additional arguments.  (Currently ignored.)}\r
+}\r
+\details{\r
+  This function is only usable for production of LaTeX documents, not\r
+  HTML.\r
+\r
+  Creates an object of class\r
+ \code{c("xtableMatharray","xtable","data.frame")}, to ensure that it is\r
+ printed by the print method \code{print.xtableMatharray}.\r
+}\r
+\value{\r
+ An object of class \code{c("xtableMatharray","xtable","data.frame")}.\r
+}\r
+\r
+\author{\r
+  David Scott <d.scott@auckland.ac.nz>\r
+}\r
+\seealso{\r
+\code{\link{print.xtableMatharray}}\r
+}\r
+\examples{\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
+mth <- xtableMatharray(V)\r
+class(mth)\r
+str(mth)\r
+unclass(mth)\r
+}\r
+\keyword{ print }\r
index 30d0e086481873d3328b3c560cf24593d18fcc4a..145982fe6af3e64a36d760816ef28b5f6b38dd9e 100644 (file)
@@ -60,22 +60,22 @@ this section was originally provided by Martin Gubri
 First load the package and create some objects.\r
 <<dataspdep>>=\r
 library(spdep)\r
-data(oldcol)\r
-COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD[], \r
+data("oldcol", package = "spdep")\r
+COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD[],\r
                         nb2listw(COL.nb))\r
 class(COL.lag.eig)\r
 COL.errW.GM <- GMerrorsar(CRIME ~ INC + HOVAL, data = COL.OLD,\r
-                          nb2listw(COL.nb, style = "W"), \r
+                          nb2listw(COL.nb, style = "W"),\r
                           returnHcov = TRUE)\r
 class(COL.errW.GM)\r
-COL.lag.stsls <- stsls(CRIME ~ INC + HOVAL, data = COL.OLD, \r
+COL.lag.stsls <- stsls(CRIME ~ INC + HOVAL, data = COL.OLD,\r
                        nb2listw(COL.nb))\r
 class(COL.lag.stsls)\r
 \r
-p1 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,], \r
+p1 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,],\r
               listw = nb2listw(COL.nb))\r
 class(p1)\r
-p2 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,], \r
+p2 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,],\r
               pred.type = "trend", type = "trend")\r
 #type option for retrocompatibility with spdep 0.5-92\r
 class(p2)\r
@@ -93,7 +93,7 @@ class(imp.sim)
 There is an \code{xtable} method for objects of this type.\r
 <<xtablesarlm, results = 'asis'>>=\r
 xtable(COL.lag.eig)\r
-@ %def \r
+@ %def\r
 \r
 The method for \code{xtable} actually uses the summary of the object,\r
 and an identical result is obtained when using the summary of the\r
@@ -119,7 +119,7 @@ print(xtable(COL.lag.eig), booktabs = TRUE)
 \r
 <<xtablegmsar, results = 'asis'>>=\r
 xtable(COL.errW.GM)\r
-@ %def \r
+@ %def\r
 \r
 \subsubsection{\code{stsls} objects}\r
 \label{sec:codestsls-objects}\r
@@ -127,7 +127,7 @@ xtable(COL.errW.GM)
 \r
 <<xtablestsls, results = 'asis'>>=\r
 xtable(COL.lag.stsls)\r
-@ %def \r
+@ %def\r
 \r
 \subsubsection{\code{sarlm.pred} objects}\r
 \label{sec:codesarlmpred-objects}\r
@@ -136,7 +136,7 @@ xtable(COL.lag.stsls)
 \r
 <<xtablesarlmpred, results = 'asis'>>=\r
 xtable(p1)\r
-@ %def \r
+@ %def\r
 \r
 This method transforms the \code{sarlm.pred} objects into data frames, allowing any number of attributes vectors which may vary according to predictor types.\r
 \r
@@ -151,12 +151,12 @@ The \code{xtable} method returns the values of direct, indirect and total impact
 \r
 <<xtablelagimpactexact, results = 'asis'>>=\r
 xtable(imp.exact)\r
-@ %def \r
+@ %def\r
 \r
 \p\r
 <<xtablelagimpactmcmc, results = 'asis'>>=\r
 xtable(imp.sim)\r
-@ %def \r
+@ %def\r
 \r
 \r
 \subsubsection{\code{spautolm} objects}\r
@@ -181,13 +181,13 @@ summary(spautolmOBJECT, Nagelkerke = TRUE)
 \p\r
 <<spautolmclass>>=\r
 class(spautolmOBJECT)\r
-@ %def \r
+@ %def\r
 \r
 \r
 <<xtablespautolm, results = 'asis'>>=\r
 xtable(spautolmOBJECT,\r
        display = c("s",rep("f", 3), "e"), digits = 4)\r
-@ %def \r
+@ %def\r
 \r
 \r
 \r
@@ -197,8 +197,8 @@ xtable(spautolmOBJECT,
 First load the package and create some objects.\r
 <<datasplm>>=\r
 library(splm)\r
-data(Produc, package = "plm")\r
-data(usaww)\r
+data("Produc", package = "plm")\r
+data("usaww",  package = "splm")\r
 fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp\r
 respatlag <- spml(fm, data = Produc, listw = mat2listw(usaww),\r
                    model="random", spatial.error="none", lag=TRUE)\r
@@ -217,19 +217,19 @@ class(imp.spml)
 \r
 <<xtablesplm, results = 'asis'>>=\r
 xtable(respatlag)\r
-@ %def \r
+@ %def\r
 \r
 \r
 \p\r
 <<xtablesplm1, results = 'asis'>>=\r
 xtable(GM)\r
-@ %def \r
+@ %def\r
 \r
 The \code{xtable} method works the same on impacts of \code{splm} models.\r
 \r
 <<xtablesplmimpacts, results = 'asis'>>=\r
 xtable(imp.spml)\r
-@ %def \r
+@ %def\r
 \r
 \subsection{The package \pkg{sphet}}\r
 \label{sec:package-pkgsphet}\r
@@ -237,10 +237,10 @@ xtable(imp.spml)
 First load the package and create some objects.\r
 <<datasphet>>=\r
 library(sphet)\r
-data(columbus)\r
+data("columbus", package = "spdep")\r
 listw <- nb2listw(col.gal.nb)\r
-data(coldis)\r
-res.stsls <- stslshac(CRIME ~ HOVAL + INC, data = columbus, listw = listw,  \r
+data("coldis", package = "sphet")\r
+res.stsls <- stslshac(CRIME ~ HOVAL + INC, data = columbus, listw = listw,\r
                       distance = coldis, type = 'Triangular')\r
 class(res.stsls)\r
 \r
@@ -257,17 +257,17 @@ class(imp.gstsls)
 \r
 <<xtablesphet, results = 'asis'>>=\r
 xtable(res.stsls)\r
-@ %def \r
+@ %def\r
 \r
 \p\r
 <<xtablesphet1, results = 'asis'>>=\r
 xtable(res.gstsls)\r
-@ %def \r
+@ %def\r
 \r
 \code{sphet} also provides a method for computing impacts.\r
 \r
 <<xtablesphetimpacts, results = 'asis'>>=\r
 xtable(imp.gstsls)\r
-@ %def \r
+@ %def\r
 \r
 \end{document}\r