在Hmisc生成的表上旋转列标题

时间:2015-11-21 00:29:58

标签: r latex r-markdown hmisc

我需要使用Hmisc包将表格从表格旋转90度。我尝试更改' colnamesTexCmd'命令但列标题没有任何变化。

以下是我的问题的可重复示例

---
 title: ""
author: ""
date: "November 20, 2015"
header-includes:
   - \usepackage{longtable, colortbl, xcolor, lscape, rotating, ctable}
output: rmarkdown::tufte_handout
---

```{r tableDescStatTest, results ='asis', echo=FALSE, message = FALSE,     warning = FALSE, include=TRUE}
library(Hmisc)

data(iris)

DescTableTest <- summary(Species ~ Sepal.Length + Sepal.Width,
                  data = iris, 
                  method = "reverse", 
                  test = T, 
                  continuous = 0)

# fuction to take the first row of comment from the latex output

mylatex <- function (...) {
  o <- capture.output(latex(...))
  # this will strip /all/ line-only comments; or if you're only
  #  interested in stripping the first such comment you could
  #  adjust accordingly
  o <- grep('^%', o, inv=T, value=T)
  cat(o, sep='\n')
  }

# render the table


options(digits = 1)
mylatex(DescTableTest, 
    exclude1 = FALSE, 
    colnamesTexCmd = "rotatebox{90}",
    npct = 'numerator', 
    npct.size = "footnotesize", 
    what = c('%'), 
    landscape = FALSE, 
    file = "", 
    long = T, 
    middle.bold = TRUE, 
    longtable = FALSE,
    overall = TRUE, 
    label = "tbl:descTable1",  
    prmsd = FALSE,
    caption = "Descriptive statistics", 
    caption.loc = 'bottom',
    where = "!htbp")

```

enter image description here

1 个答案:

答案 0 :(得分:0)

您正在使用课程summary.formula.reverse

的S3乳胶方法
  

? Hmisc :: summary.formula

不接受参数colnamesTexCmd