gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 09:43:26 25 4
gpt4 key购买 nike

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

最佳答案

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

? Hmisc::summary.formula

不接受参数 colnamesTexCmd

关于在 Hmisc 生成的表上旋转列标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33838270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com