我想用kable打印观星者表。
当我在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)
我的输出如下所示:
这是我的表格代码(有一些更改):
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)
仅在多行/矩形之后打印表。我也从其他计算机上运行了代码,然后问题就没有发生。是什么导致了这种情况?
发布于 2017-10-03 14:17:15
更新:经过大量的研究,我发现这个问题只有在我的R版本从3.4.0更新到3.4.1之后才会出现。在更新到新版本后,它还使我从1.16更新到1.17版本,只有该版本才会出现上述错误。所以,我从1.17降级到1.16,这就解决了问题。
发布于 2018-03-17 16:14:49
您不需要使用kable()
函数来生成markdown中的stargrazer
表。只需在包含stargrazer()
的块的开头添加{r results='asis'}
即可。
https://stackoverflow.com/questions/46261914
复制相似问题