繁体   English   中英

凯布尔(Kable)打印多行观星台

[英]kable prints stargazer table with multiple lines

我想用电缆打印观星台。
当我在markdown中运行代码时,我得到了stargazer表,但是带有多行并带有符号| 在表格前的那些行之间。
一开始我还会收到警告消息:

Warning in kable_markdown(x = structure(c("", "<table style=\"text-
align:center\"><caption><strong>Crude models: OR for mRS at discharge >3
with 95% CI</strong></caption>", : The table should have a header (column
names)

我的输出看起来像这样:

打印观星台时出现kable错误

这是我的表代码(有一些更改):

mod.example1 <- glm(bad_outcome~x1+x2+x3+x4, family = "binomial", data = dat0)
mod.example2 <- glm(bad_outcome~x1+x2+x3+x4, family = "binomial", data = dat1)

CI.list <- list(exp(confint(mod.example1)),exp(confint(mod.example2)))

my.stg <- stargazer(
title = "my models: OR for bad outcome",
mod.example1
mod.example2,
type="html",
digits = 2,
t.auto = FALSE,
model.numbers = F,
keep.stat = "n",
report = c("vc*sp"),
omit = "Constant",
star.cutoffs = c(0.05,0.01,0.001),
no.space = FALSE,
single.row = F,
dep.var.labels = c("***bad outcome***"),
covariate.labels = c("x1","x2","x3","x4"),
column.labels = c("-**dat0**-", "-**dat1**-"),
ci= T,
ci.custom = CI.list,
apply.coef=exp)

并在一个新的块中:

kable(my.stg)

表格被打印,但仅在多行/矩形之后打印。 我还从其他计算机上运行了代码,然后问题没有发生。 是什么原因造成的?

更新:经过大量研究,我意识到只有将我的R版本从3.4.0更新到3.4.1后才出现问题。 更新到新版本后,它也使我将knitr软件包从1.16更新到1.17,只有该版本才给出上述错误。 因此,我将Knitr的等级从1.17降级到1.16,从而解决了该问题。

您不需要使用kable()函数在markdown中生成stargrazer表。 只需在包含stargrazer()的块的开头添加{r results='asis'}即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM