[英]Stargazer Title Not Showing (Non-reproducible Error)
WARNING: I was not able to reproduce the error in a separate R/RStudio session, so I am hoping just to get some leads on trouble shooting my current .rmd
script. 警告:我无法在单独的R / RStudio会话中重现该错误,因此我希望能在解决当前
.rmd
脚本问题时获得一些.rmd
。
The Problem 问题
All of a sudden, the stargazer title argument seemed to stop working. 突然之间,观星人的称号争论似乎停止了。 No matter what the title was or where I placed the argument within the function, it does not seem to work.
无论标题是什么,或者我在函数中的位置如何,它似乎都不起作用。
Additionally, and maybe related, I started getting this warning message: 此外,也许与此相关,我开始收到以下警告消息:
the condition has length > 1 and only the first element will be used
Background 背景
After @hpesoj626 helped me answer this question , the titles disappeared from my tables. 在@ hpesoj626帮助我回答了这个问题之后 ,标题从我的表中消失了。 Though not explicitly set in that example,
stargazer
's / LaTeX
's default title was still being shown. 尽管在该示例中未明确设置,但
stargazer
的/ LaTeX
的默认标题仍在显示。 After using the solution in that post, the titles disappeared. 在该帖子中使用了解决方案后,标题消失了。
I wanted to add a customized title to the tables by using the title = ""
argument. 我想通过使用
title = ""
参数向表中添加自定义标题。 This doesn't seem to help. 这似乎没有帮助。
Attempts 尝试次数
dep.var.labels = c()
, and everything seems to work just fine. dep.var.labels = c()
,并且一切似乎都可以正常工作。 stargazer
package. stargazer
软件包。 ...
and title = ""
...
和title = ""
以外的所有其他参数 results='asis'
, echo=FALSE
, etc.) results='asis'
, echo=FALSE
等) As you will see in the below section, I have other packages loaded via namespace since I am loading .rda
objects into my session using load()
. 正如您将在下一节中看到的那样,由于要使用
load()
将.rda
对象加载到会话中,因此我还通过命名空间加载了其他软件包。 I am loading glm()
objects and ggplot()
objects into my R/Rstudio session. 我正在将
glm()
对象和ggplot()
对象加载到我的R / Rstudio会话中。 Even when doing this in the example session, I have not able to reproduce the error. 即使在示例会话中执行此操作,我也无法重现该错误。
Differences Between Linked Reproducible example and Actual Session 链接的可复制示例与实际会话之间的差异
The only differences I can see between my example data and my actual data is that the generated LaTeX code for my actual data is missing this: 我可以看到的示例数据和实际数据之间的唯一区别是,为我的实际数据生成的LaTeX代码缺少以下内容:
\begin{table}[!htbp] \centering
\caption{}
\label{}
My actual data contains this: 我的实际数据包含以下内容:
the condition has length > 1 and only the first element will be used
And my actual sessionInfo() has a few more packages loaded via namespace: 我实际的sessionInfo()还有一些通过名称空间加载的软件包:
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] stargazer_5.2.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 digest_0.6.15 grid_3.4.4 plyr_1.8.4 gtable_0.2.0 scales_0.5.0.9000 ggplot2_2.2.1 pillar_1.2.1 rlang_0.2.0.9001
[10] lazyeval_0.2.1 labeling_0.3 tools_3.4.4 munsell_0.4.3 yaml_2.1.19 compiler_3.4.4 colorspace_1.3-2 knitr_1.20 tibble_1.4.2
Do some of the packages loaded via namespace conflict with stargazer
, LaTeX
, or other packages? 通过命名空间加载的某些软件包是否与
stargazer
, LaTeX
或其他软件包冲突?
Thanks 谢谢
I know I wasn't able to provide the most information, given I wasn't able to reproduce the error myself, but I do appreciate any insight you might have on trouble shooting the problem. 考虑到我自己无法重现该错误,我知道我无法提供最多的信息,但是对于您在解决问题时可能遇到的任何见解,我深表感谢。 If you are able to provide some guidance, thank you.
如果您能够提供一些指导,则谢谢。
After lots of trial and error, I was able to figure out a solution. 经过大量的反复试验,我终于找到了解决方案。
I had not realized this, but including float = FALSE
in the stargazer()
function, removes this part of the generated LaTeX code: 我没有意识到这一点,但是在
stargazer()
函数中包含float = FALSE
会删除生成的LaTeX代码的这一部分:
\begin{table}[!htbp] \centering
\caption{}
\label{}
Which is where the title would go. 标题会去哪儿。 But without using the
float = FALSE
, I wouldn't be able to position my tables where I wanted. 但是如果不使用
float = FALSE
,我将无法将表放置在所需的位置。 And table.placement = "htbp"
or any combination of those letters didn't position the tables properly and table.placement = "H"
threw an error. 并且
table.placement = "htbp"
或这些字母的任何组合都无法正确定位表,并且table.placement = "H"
引发了错误。
Thanks to this post , I was able to put the following code in my YAML header and use table.placement = "H"
and keep float = TRUE
: 感谢这篇文章 ,我能够将以下代码放入YAML标头中,并使用
table.placement = "H"
并保持float = TRUE
:
---
title: "Title"
author: "Name"
output: pdf_document
fig.caption: yes
keep_tex: yes
header-includes: \usepackage{float}
---
Which places my tables in the appropriate place AND allows me to put titles on the tables. 将我的桌子放置在适当的位置,并允许我在桌子上放置标题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.