【问题标题】:Rotate column headers on Hmisc generated table在 Hmisc 生成的表上旋转列标题
【发布时间】:2016-02-23 14:59:45
【问题描述】:

我需要使用 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")

```

【问题讨论】:

    标签: r latex r-markdown hmisc


    【解决方案1】:

    您正在为 summary.formula.reverse 类使用 S3 乳胶方法

    ? Hmisc::summary.formula

    不接受参数colnamesTexCmd

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-12
      • 1970-01-01
      • 2023-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-22
      • 2023-01-15
      相关资源
      最近更新 更多