]> git.donarmstrong.com Git - xtable.git/commitdiff
Added "rotate.rownames" and "rotate.colnames" arguments as suggested by Marcus Loeche...
authorroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 30 Jan 2012 15:48:54 +0000 (15:48 +0000)
committerroosen <roosen@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 30 Jan 2012 15:48:54 +0000 (15:48 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@24 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/NEWS
pkg/R/print.xtable.R
pkg/inst/doc/xtableGallery.snw
pkg/man/print.xtable.Rd

index 0498e4202d63558c13b3feab2772dffc3814f988..78eefef3eb78b10cd63a8fc39e11df419e24c670 100644 (file)
--- a/pkg/NEWS
+++ b/pkg/NEWS
@@ -7,6 +7,8 @@
     pass additional arguments such as "big.marks" to "formatC()".
   * Added "short.caption" argument to "print" to let the user 
     specify a Latex short caption used when creating a list of tables. 
+  * Added "rotate.colnames" and "rotate.rownames" arguments to
+    "print.xtable".  
   * Added an "is.null()" check on the "table.placement" argument.
   * Put in some changes from John Leonard regarding the placement
     of newlines when "longtable" and "add.to.row" are used together.
index 9b73f311045df0c0d8d7929b2d49dc16e5d71a97..2c1c5dc25440a9db8a67a2b54f18a6735a8ecf68 100644 (file)
@@ -47,6 +47,8 @@ print.xtable <- function(
   print.results=TRUE,\r
   format.args=NULL,\r
   short.caption=NULL,\r
+  rotate.rownames=FALSE,\r
+  rotate.colnames=FALSE,\r
   ...) {\r
   # Claudio Agostinelli <claudio@unive.it> dated 2006-07-28 hline.after\r
   # By default it print an \hline before and after the columns names independently they are printed or not and at the end of the table\r
@@ -324,22 +326,37 @@ print.xtable <- function(
   # Claudio Agostinelli <claudio@unive.it> dated 2006-07-28 include.colnames, include.rownames \r
   if (include.colnames) {\r
     result <- result + BROW + BTH\r
-    if (include.rownames) result <- result + STH\r
-    if (is.null(sanitize.colnames.function)) {                                     # David G. Whiting in e-mail 2007-10-09\r
-      result <- result + paste(sanitize(names(x)),collapse=STH)\r
-    } else {\r
-      result <- result + paste(sanitize.colnames.function(names(x)), collapse=STH) # David G. Whiting in e-mail 2007-10-09\r
-    }\r
+    if (include.rownames) {\r
+         result <- result + STH\r
+       }  \r
+    # David G. Whiting in e-mail 2007-10-09\r
+    if (is.null(sanitize.colnames.function)) {                                     \r
+         CNAMES <- sanitize(names(x))\r
+       } else {\r
+      CNAMES <- sanitize.colnames.function(names(x))\r
+       }\r
+    if (rotate.colnames) {\r
+         #added by Markus Loecher, 2009-11-16\r
+      CNAMES <- paste("\\begin{sideways}", CNAMES, "\\end{sideways}")\r
+       }       \r
+    result <- result + paste(CNAMES, collapse=STH)\r
+\r
     result <- result + ETH + EROW\r
   }\r
 \r
   cols <- matrix("",nrow=nrow(x),ncol=ncol(x)+pos)\r
   if (include.rownames) {\r
-    if (is.null(sanitize.rownames.function)) {                                     # David G. Whiting in e-mail 2007-10-09\r
-      cols[,1] <- sanitize(row.names(x))\r
+    # David G. Whiting in e-mail 2007-10-09\r
+    if (is.null(sanitize.rownames.function)) {                                     \r
+      RNAMES <- sanitize(row.names(x))\r
     } else {\r
-      cols[,1] <- sanitize.rownames.function(row.names(x))                         # David G. Whiting in e-mail 2007-10-09\r
+      RNAMES <- sanitize.rownames.function(row.names(x))                         \r
     }\r
+    if (rotate.rownames) {\r
+         #added by Markus Loecher, 2009-11-16\r
+      RNAMES <- paste("\\begin{sideways}", RNAMES, "\\end{sideways}")\r
+       }       \r
+       cols[,1] <- RNAMES\r
   }\r
 \r
 ## Begin vectorizing the formatting code by Ian Fellows [ian@fellstat.com]\r
index 2298c93bb9756a1fad1dd74dd356405a7099014c..79d1626e6f43c9680a323d11705e8216391e2a56 100644 (file)
@@ -388,6 +388,14 @@ print(tli.table,include.colnames=FALSE,floating=FALSE,hline.after=c(0,nrow(tli.t
 print((tli.table),include.colnames=FALSE,include.rownames=FALSE,floating=FALSE)
 @
 
+\subsection{Rotate row and column names}
+The {\tt rotate.rownames } and {\tt rotate.colnames} arguments can be
+used to rotate the row and/or column names.
+
+<<results=tex>>=
+print((tli.table),rotate.rownames=TRUE,rotate.colnames=TRUE)
+@
+
 \subsection{Horizontal lines}
 <<results=tex>>=
 print(xtable(anova(glm.D93)),hline.after=c(1),floating=FALSE)
index fdf2df9af81d33ee11d81c290f3f33d365912c60..877fc04b358124d145fe673ce0ecff121554ef81 100644 (file)
                html.table.attributes="border=1", 
                print.results=TRUE, 
         format.args=NULL, 
-               short.caption=NULL, ...)}
+               short.caption=NULL, 
+               rotate.rownames = FALSE,
+               rotate.colnames = FALSE,
+               ...)}
 \arguments{
   \item{x}{An object of class \code{"xtable"}.}
   \item{type}{Type of table to produce.  Possible values for \code{type} are \code{"latex"} or \code{"html"}.
@@ -49,6 +52,8 @@
   \item{print.results}{If \code{TRUE}, the generated table is printed to standard output.  Set this to \code{FALSE} if you will just be using the character vector that is returned invisibly.}
   \item{format.args}{List of arguments for the \code{formatC} function.  For example, standard German number separators can be specified as \code{format.args=list(big.mark = "'", decimal.mark = ","))}.}
   \item{short.caption}{A "short caption" can be specified that gets used as the table descriptor when LaTeX generates a "List of Tables".}
+  \item{rotate.rownames}{If \code{TRUE}, the row names are displayed vertically in LaTeX.}
+  \item{rotate.colnames}{If \code{TRUE}, the column names are displayed vertically in LaTeX.}
   \item{...}{Additional arguments.  (Currently ignored.)}
 }
 \details{