观星者标题未显示(Non-reproducible 错误)

Stargazer Title Not Showing (Non-reproducible Error)

警告:我无法在单独的 R/RStudio session 中重现该错误,因此我希望能获得一些解决当前 .rmd 脚本问题的线索。

问题

突然之间,观星者头衔的争论似乎停止了。无论标题是什么或我将参数放在函数中的什么位置,它似乎都不起作用。

此外,也许相关的是,我开始收到此警告消息:

the condition has length > 1 and only the first element will be used

背景

@hpesoj626 帮我回答后 ,标题从我的表格中消失了。尽管在那个例子中没有明确设置,stargazer's / LaTeX's default title 仍然被显示。使用post中的解决方案后,标题消失了。

我想使用 title = "" 参数为表格添加自定义标题。这似乎没有帮助。

尝试次数

正如您将在下一节中看到的那样,我通过命名空间加载了其他包,因为我使用 load().rda objects 加载到我的 session 中。我正在将 glm() objects 和 ggplot() objects 加载到我的 R/Rstudio session 中。即使在示例 session 中这样做,我也无法重现错误。

链接的可重现示例与实际示例之间的差异 Session

我能看到我的示例数据和我的实际数据之间的唯一区别是为我的实际数据生成的 LaTeX 代码缺少这个:

\begin{table}[!htbp] \centering 
  \caption{} 
  \label{} 

我的实际数据包含:

the condition has length > 1 and only the first element will be used

我的实际 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    

通过命名空间加载的某些包是否与 stargazerLaTeX 或其他包冲突?

谢谢

我知道我无法提供最多的信息,因为我自己无法重现该错误,但我非常感谢您对解决问题的任何见解。如果您能提供一些指导,谢谢。

经过反复试验,我找到了解决方案。

我没有意识到这一点,但是在 stargazer() 函数中包含 float = FALSE,删除了生成的 LaTeX 代码的这一部分:

\begin{table}[!htbp] \centering 
  \caption{} 
  \label{}

这就是标题所在的位置。但是如果不使用 float = FALSE,我将无法将我的表格放置在我想要的位置。 table.placement = "htbp" 或这些字母的任意组合没有正确定位表格,table.placement = "H" 引发错误。

感谢 this post,我能够将以下代码放入我的 YAML header 并使用 table.placement = "H" 并保持 float = TRUE:

---
title: "Title"
author: "Name"
output: pdf_document
fig.caption: yes
keep_tex: yes
header-includes: \usepackage{float}
---

将我的表格放在适当的位置并允许我在表格上放置标题。