Search code examples
rr-markdownstargazer

getting rid of "table.1" from the top of stargazer


I'm wondering how to remove the "Table.1" at the top of my stargazer table.

I used right now created a new code chunk in my r document and ran the stargazercommand.

```
{r mylatextable, results = "asis"}
stargazer(lm3a,lm3b,lm3c,lm3d, type = 'latex',header=FALSE)
```

I got the following table:

enter image description here

at the very top we see this "Table.1" text. How do I remove it?


Solution

  • The "Table.1" text is autogenerated by Latex, from the \caption{} tag. You can remove the \caption line using sub to suppress this. Here's an example reproducible Rmd document to demonstrate:

    ---
    output: pdf_document
    ---
    
    ```{r setup, include=FALSE}
    library(stargazer)
    star = stargazer(attitude, header = F)
    star = sub('^.+\\caption.+$','', star)
    ```
    
    ```{r mylatextable, results = "asis", echo=FALSE}
    cat(star, sep='\n')
    ```
    

    enter image description here