]> git.donarmstrong.com Git - xtable.git/commitdiff
Set options(xtable.floating = FALSE) instead of repeating 37 times
authorarnima <arnima@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 29 Sep 2014 16:56:20 +0000 (16:56 +0000)
committerarnima <arnima@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
Mon, 29 Sep 2014 16:56:20 +0000 (16:56 +0000)
git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@57 edb9625f-4e0d-4859-8d74-9fd3b1da38cb

pkg/vignettes/xtableGallery.Rnw

index ce5d600b0f4ace6ddf5ef50f716f9fa2baed31c2..c45370d27efa95936578dbde0918a064d2867e72 100644 (file)
@@ -74,6 +74,7 @@ options(replace.assign = TRUE, width = 60,
 Load example dataset\r
 <<>>=\r
 library(xtable)\r
+options(xtable.floating = FALSE)\r
 data(tli)\r
 \r
 ## Demonstrate data.frame\r
@@ -81,7 +82,7 @@ tli.table <- xtable(tli[1:10, ])
 digits(tli.table)[c(2,6)] <- 0\r
 @\r
 <<results='asis'>>=\r
-print(tli.table, floating = FALSE)\r
+tli.table\r
 @\r
 \r
 \newpage\r
@@ -92,7 +93,7 @@ design.matrix <- model.matrix(~ sex*grade, data = tli[1:10, ])
 design.table <- xtable(design.matrix)\r
 @\r
 <<results='asis'>>=\r
-print(design.table, floating = FALSE)\r
+design.table\r
 @\r
 \r
 \subsection{aov}\r
@@ -101,7 +102,7 @@ fm1 <- aov(tlimth ~ sex + ethnicty + grade + disadvg, data = tli)
 fm1.table <- xtable(fm1)\r
 @\r
 <<results='asis'>>=\r
-print(fm1.table, floating = FALSE)\r
+fm1.table\r
 @\r
 \subsection{lm}\r
 <<>>=\r
@@ -109,20 +110,20 @@ fm2 <- lm(tlimth ~ sex*ethnicty, data = tli)
 fm2.table <- xtable(fm2)\r
 @\r
 <<results='asis'>>=\r
-print(fm2.table, floating = FALSE)\r
+fm2.table\r
 @\r
 \r
 \vspace{12pt}\textbf{\itshape An anova object}\r
 \r
 <<results='asis'>>=\r
-print(xtable(anova(fm2)), floating = FALSE)\r
+xtable(anova(fm2))\r
 @\r
 \vspace{12pt}\textbf{\itshape Another anova object}\r
 <<>>=\r
 fm2b <- lm(tlimth ~ ethnicty, data = tli)\r
 @\r
 <<results='asis'>>=\r
-print(xtable(anova(fm2b, fm2)), floating = FALSE)\r
+xtable(anova(fm2b, fm2))\r
 @\r
 \r
 \r
@@ -135,12 +136,12 @@ fm3 <- glm(disadvg ~ ethnicty*grade, data = tli, family = binomial())
 fm3.table <- xtable(fm3)\r
 @\r
 <<results='asis'>>=\r
-print(fm3.table, floating = FALSE)\r
+fm3.table\r
 @\r
 \r
 \vspace{12pt}\textbf{\itshape An anova object}\r
 <<results='asis'>>=\r
-print(xtable(anova(fm3)), floating = FALSE)\r
+xtable(anova(fm3))\r
 @\r
 \r
 \r
@@ -163,26 +164,26 @@ npk.aovE <- aov(yield ~  N*P*K + Error(block), npk)
 options(op)\r
 @\r
 <<results='asis'>>=\r
-print(xtable(npk.aov), floating = FALSE)\r
+xtable(npk.aov)\r
 @\r
 \r
 \vspace{12pt}\textbf{\itshape An anova object}\r
 <<results='asis'>>=\r
-print(xtable(anova(npk.aov)), floating = FALSE)\r
+xtable(anova(npk.aov))\r
 @\r
 \r
 \vspace{12pt}\textbf{\itshape Another anova object}\r
 <<results='asis'>>=\r
-print(xtable(summary(npk.aov)), floating = FALSE)\r
+xtable(summary(npk.aov))\r
 @\r
 \r
 <<results='asis'>>=\r
-print(xtable(npk.aovE), floating = FALSE)\r
+xtable(npk.aovE)\r
 @\r
 \r
 \r
 <<results='asis'>>=\r
-print(xtable(summary(npk.aovE)), floating = FALSE)\r
+xtable(summary(npk.aovE))\r
 @\r
 \r
 \subsection{More lm}\r
@@ -199,12 +200,12 @@ weight <- c(ctl, trt)
 lm.D9 <- lm(weight ~ group)\r
 @\r
 <<results='asis'>>=\r
-print(xtable(lm.D9), floating = FALSE)\r
+xtable(lm.D9)\r
 @\r
 \r
 \r
 <<results='asis'>>=\r
-print(xtable(anova(lm.D9)), floating = FALSE)\r
+xtable(anova(lm.D9))\r
 @\r
 \r
 \subsection{More glm}\r
@@ -221,7 +222,7 @@ d.AD <- data.frame(treatment, outcome, counts)
 glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())\r
 @\r
 <<results='asis'>>=\r
-print(xtable(glm.D93, align = "r|llrc"), floating = FALSE)\r
+xtable(glm.D93, align = "r|llrc")\r
 @\r
 \r
 \subsection{prcomp}\r
@@ -234,14 +235,12 @@ if(require(stats, quietly = TRUE)) {
 }\r
 @\r
 <<results='asis'>>=\r
-if(require(stats, quietly = TRUE)) {\r
-  print(xtable(pr1), floating = FALSE)\r
-}\r
+xtable(pr1)\r
 @\r
 \r
 \r
 <<results='asis'>>=\r
-  print(xtable(summary(pr1)), floating = FALSE)\r
+xtable(summary(pr1))\r
 @\r
 \r
 \r
@@ -250,7 +249,7 @@ if(require(stats, quietly = TRUE)) {
 #  ## Demonstrate princomp\r
 #  ## Taken from help(princomp) in mva package of R 1.1.1\r
 #  pr2 <- princomp(USArrests)\r
-#  print(xtable(pr2))\r
+#  xtable(pr2)\r
 @\r
 \r
 \subsection{Time series}\r
@@ -262,7 +261,7 @@ temp.table <- xtable(temp.ts, digits = 0)
 caption(temp.table) <- "Time series example"\r
 @\r
 <<results='asis'>>=\r
-    print(temp.table, floating = FALSE)\r
+temp.table\r
 @\r
 <<savetofile,echo=FALSE>>=\r
 if (FALSE) {\r
@@ -338,7 +337,7 @@ colnames(insane)[2] <- paste(insane[, 2], collapse = "")
 @\r
 \r
 <<pxti,results='asis'>>=\r
-print( xtable(insane), floating = FALSE)\r
+xtable(insane)\r
 @\r
 \r
 \vspace{12pt}\r
@@ -401,7 +400,7 @@ tli.table <- xtable(tli[1:10, ])
 align(tli.table) <- rep("r", 6)\r
 @\r
 <<results='asis'>>=\r
-print(tli.table, floating = FALSE)\r
+tli.table\r
 @\r
 \r
 \vspace{12pt}\r
@@ -410,14 +409,14 @@ print(tli.table, floating = FALSE)
 align(tli.table) <- "|rrl|l|lr|"\r
 @\r
 <<results='asis'>>=\r
-print(tli.table, floating = FALSE)\r
+tli.table\r
 @\r
 \vspace{12pt}\textbf{\itshape Fixed width columns}\r
 <<>>=\r
 align(tli.table) <- "|rr|lp{3cm}l|r|"\r
 @\r
 <<results='asis'>>=\r
-print(tli.table, floating = FALSE)\r
+tli.table\r
 @\r
 \r
 \subsection{Significant digits}\r
@@ -428,7 +427,7 @@ Specify with a single argument
 digits(tli.table) <- 3\r
 @\r
 <<results='asis'>>=\r
-print(tli.table, floating = FALSE)\r
+tli.table\r
 @\r
 \r
 \r
@@ -438,7 +437,7 @@ or one for each column, counting the row names,
 digits(tli.table) <- 1:(ncol(tli)+1)\r
 @\r
 <<results='asis'>>=\r
-print(tli.table, floating = FALSE)\r
+tli.table\r
 @\r
 \r
 \vspace{12pt}\r
@@ -447,12 +446,12 @@ or as a full matrix
 digits(tli.table) <- matrix( 0:4, nrow = 10, ncol = ncol(tli)+1 )\r
 @\r
 <<results='asis'>>=\r
-print(tli.table, floating = FALSE)\r
+tli.table\r
 @\r
 \r
 \subsection{Suppress row names}\r
 <<results='asis'>>=\r
-print((tli.table), include.rownames = FALSE, floating = FALSE)\r
+print(tli.table, include.rownames = FALSE)\r
 @\r
 \r
 \vspace{12pt} If you want a vertical line on the left, you need to\r
@@ -461,7 +460,7 @@ change the \code{align} attribute.
 align(tli.table) <- "|r|r|lp{3cm}l|r|"\r
 @\r
 <<results='asis'>>=\r
-print((tli.table), include.rownames = FALSE, floating = FALSE)\r
+print(tli.table, include.rownames = FALSE)\r
 @\r
 \r
 \vspace{12pt} Revert the alignment to what is was before.\r
@@ -471,20 +470,19 @@ align(tli.table) <- "|rr|lp{3cm}l|r|"
 \r
 \subsection{Suppress column names}\r
 <<results='asis'>>=\r
-print((tli.table), include.colnames = FALSE, floating = FALSE)\r
+print(tli.table, include.colnames = FALSE)\r
 @\r
 \r
 \vspace{12pt}\r
 Note the doubled header lines which can be suppressed with, eg,\r
 <<results='asis'>>=\r
-print(tli.table, include.colnames = FALSE, floating = FALSE,\r
+print(tli.table, include.colnames = FALSE,\r
       hline.after = c(0,nrow(tli.table)))\r
 @\r
 \r
 \subsection{Suppress row and column names}\r
 <<results='asis'>>=\r
-print((tli.table), include.colnames = FALSE, include.rownames = FALSE,\r
-      floating = FALSE)\r
+print(tli.table, include.colnames = FALSE, include.rownames = FALSE)\r
 @\r
 \r
 \subsection{Rotate row and column names}\r
@@ -492,7 +490,7 @@ The \texttt{rotate.rownames } and \texttt{rotate.colnames} arguments can be
 used to rotate the row and/or column names.\r
 \r
 <<results='asis'>>=\r
-print((tli.table), rotate.rownames = TRUE, rotate.colnames = TRUE)\r
+print(tli.table, rotate.rownames = TRUE, rotate.colnames = TRUE)\r
 @\r
 \r
 \subsection{Horizontal lines}\r
@@ -503,7 +501,7 @@ Use the \texttt{hline.after} argument to specify the position of the
 horizontal lines.\r
 \r
 <<results='asis'>>=\r
-print(xtable(anova(glm.D93)), hline.after = c(1), floating = FALSE)\r
+print(xtable(anova(glm.D93)), hline.after = c(1))\r
 @\r
 \r
 \vspace{12pt}\textbf{\itshape Line styles}\r
@@ -532,7 +530,7 @@ although they are part of the \texttt{booktabs} package.
 \lightrulewidth = 0.5pt\r
 \r
 <<results='asis'>>=\r
-print(tli.table, booktabs = TRUE, floating = FALSE)\r
+print(tli.table, booktabs = TRUE)\r
 @\r
 \r
 \vspace{12pt}\r
@@ -550,13 +548,13 @@ hlines <- c(-1,0,1,nrow(bktbs))
 @\r
 This command produces the required table.\r
 <<results='asis'>>=\r
-print(bktbs, booktabs = TRUE, hline.after = hlines, floating = FALSE)\r
+print(bktbs, booktabs = TRUE, hline.after = hlines)\r
 @\r
 \r
 \r
 \subsection{Table-level LaTeX}\r
 <<results='asis'>>=\r
-print(xtable(anova(glm.D93)), size = "small", floating = FALSE)\r
+print(xtable(anova(glm.D93)), size = "small")\r
 @\r
 \r
 \r
@@ -571,7 +569,7 @@ x.big <- xtable(x, label = 'tabbig',
                 caption = 'Example of \\code{longtable} spanning several pages')\r
 @\r
 <<results='asis'>>=\r
-print(x.big, tabular.environment = 'longtable', floating = FALSE)\r
+print(x.big, tabular.environment = 'longtable')\r
 @\r
 \r
 %%\r
@@ -600,7 +598,7 @@ print(x.big, tabular.environment = 'longtable', floating = FALSE)
 %    "  \\endlastfoot \n", sep = ""))\r
 %x.big2 <- xtable(x, label = "tabbig2",\r
 %    caption = "Example of longtable with the header on each page")\r
-%print(x.big2, tabular.environment = "longtable", floating = FALSE,\r
+%print(x.big2, tabular.environment = "longtable",\r
 %include.rownames = FALSE, add.to.row = addtorow, hline.after = c(-1) )\r
 %@\r
 \r
@@ -616,7 +614,7 @@ x.small <- xtable(x, label = 'tabsmall', caption = 'A sideways table')
 @\r
 \r
 <<results='asis'>>=\r
-print(x.small, floating.environment = 'sidewaystable')\r
+print(x.small, floating = TRUE, floating.environment = 'sidewaystable')\r
 @\r
 \clearpage\r
 \r