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