3

So I'm also preparing a table or regression results in stargazer, and I'm only showing the t-scores in the table from 10 different models side by side. I have the same question as in this earlier post on how to remove the "t = " from the stargazer results output from @deca.

I've followed the answer given by @JNWHH, which is:

  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".

After completing these three steps and then calling the stargazer function again, I can see in the LaTeX code produced for my table that all of the "t = " have been removed. However, when I knit the document, the resulting PDF still has the "t = " in them.

I wasn't sure what/if code was needed here for people to diagnose, but if so, please let me know and I can try to include what I'm running. But really, I'm just following the three steps above exactly as described. I have not restarted my R-session since editing the source code, so I don't think the problem stems from that. If I'm missing something obvious, thanks for letting me know.

anguyen1210
  • 513
  • 5
  • 21

1 Answers1

1

I gone through the solution. You have to adjust the stargazer source code while knitting the document. This is true for either text in html or latex in PDF output.

---
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")
```

While producing the document this opens the source code.

enter image description here

You can more easily find the part .format.t.stats.left (lines 7105 and 7106 at 13.01.2023) by searching the text file. You modify the style, e.g. change it to square brackets.

enter image description here

Marco
  • 2,368
  • 6
  • 22
  • 48