From: dscott Date: Sun, 17 Jan 2016 10:26:18 +0000 (+0000) Subject: Further changes to xtableFtable.R regarding rotation of text X-Git-Url: https://git.donarmstrong.com/?p=xtable.git;a=commitdiff_plain;h=bd48a7f361867bbe275f99284247daf3dd8789cf Further changes to xtableFtable.R regarding rotation of text git-svn-id: svn://scm.r-forge.r-project.org/svnroot/xtable@98 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- diff --git a/pkg/R/xtableFtable.R b/pkg/R/xtableFtable.R index fd32d11..46c7f7b 100644 --- a/pkg/R/xtableFtable.R +++ b/pkg/R/xtableFtable.R @@ -113,23 +113,30 @@ print.xtableFtable <- function(x, 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 - } + ## if (method == "compact"){ + ## if (rotate.rownames) rotate.colnames <- TRUE + ## if (rotate.colnames) rotate.rownames <- TRUE + ## } ## rotations are possible if (rotate.rownames){ - fmtFtbl[nCharRows, 1:(nCharCols - 1)] <- + fmtFtbl[1:dim(fmtFtbl)[1], 1:(nCharCols - 1)] <- paste0("\\begin{sideways} ", - fmtFtbl[nCharRows, 1:(nCharCols - 1)], + fmtFtbl[1:dim(fmtFtbl)[1], 1:(nCharCols - 1)], "\\end{sideways}") } if (rotate.colnames){ - fmtFtbl[1:(nCharRows), nCharCols - 1] <- - paste0("\\begin{sideways} ", - fmtFtbl[1:(nCharRows), nCharCols - 1], - "\\end{sideways}") + if (rotate.rownames){ + fmtFtbl[1:(nCharRows), (nCharCols):dim(fmtFtbl)[2]] <- + paste0("\\begin{sideways} ", + fmtFtbl[1:(nCharRows), (nCharCols):dim(fmtFtbl)[2]], + "\\end{sideways}") + } else { + fmtFtbl[1:(nCharRows), 1:dim(fmtFtbl)[2]] <- + paste0("\\begin{sideways} ", + fmtFtbl[1:(nCharRows), 1:dim(fmtFtbl)[2]], + "\\end{sideways}") + } } diff --git a/pkg/vignettes/xtableGallery.Rnw b/pkg/vignettes/xtableGallery.Rnw index 807e8f6..721b78e 100644 --- a/pkg/vignettes/xtableGallery.Rnw +++ b/pkg/vignettes/xtableGallery.Rnw @@ -156,7 +156,8 @@ print.xtableFtable(xftbl) \p <>= xftbl <- xtableFtable(tbl, method = "row.compact") -print.xtableFtable(xftbl, rotate.colnames = TRUE) +print.xtableFtable(xftbl, rotate.colnames = TRUE, + rotate.rownames = TRUE) @ %def \p