gpt4 book ai didi

r - 编辑 stargazer 源代码——保存的编辑不会呈现为 pdf

转载 作者:行者123 更新时间:2023-12-05 07:26:13 25 4
gpt4 key购买 nike

因此,我还在 stargazer 中准备了一个表格或回归结果,我只在表格中并排显示了 10 个不同模型的 t 分数。我有与之前关于 how to remove the "t = " from the stargazer results output 的帖子相同的问题来自@deca。

我遵循了@JNWHH 给出的答案,即:

  1. Access the edit-screen of the stargazer function with trace(stargazer:::.stargazer.wrap, edit = T)
  2. Go to line 7103/7104 (may be different depending on your stargazer version) and look for .format.t.stats.left <- "t = " and .format.t.stats.right <- "" and edit it to your liking, e.g., .format.t.stats.left <- "[" and .format.t.stats.right <- "]"
  3. Confirm with "save".

完成这三个步骤然后再次调用 stargazer 函数后,我可以在为我的表生成的 LaTeX 代码中看到所有“t =”都已被删除。但是,当我编织文档时,生成的 PDF 中仍然包含“t =”。

我不确定这里是否需要什么代码供人们诊断,但如果需要,请告诉我,我可以尝试包括我正在运行的代码。但实际上,我只是完全按照上述三个步骤进行操作。自从编辑源代码以来,我没有重新启动我的 R-session,所以我不认为问题源于此。如果我遗漏了一些明显的东西,谢谢你让我知道。

最佳答案

我已经完成了解决方案。在编写文档时,您必须调整 stargazer 源代码。对于 html 中的文本或 PDF 输出中的 latex 都是如此。

---
title: "stargazer_edits"
author: "Me"
date: "2023-01-13"
output:
html_document: default
pdf_document: default
---

## stargazer source edited

```{r, echo=FALSE, warning=FALSE, message=FALSE}
library(stargazer)

# I do this once
trace(stargazer:::.stargazer.wrap, edit = T)

model <- lm(mpg ~ disp + cyl, data=mtcars)

stargazer(model, type = "text", report = "vc*t")
```

在生成文档时,这会打开源代码。

enter image description here

您可以通过搜索文本文件更轻松地找到 .format.t.stats.left 部分(2023 年 1 月 13 日第 7105 和 7106 行)。您修改样式,例如将其更改为方括号。

enter image description here

关于r - 编辑 stargazer 源代码——保存的编辑不会呈现为 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54512289/

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