Search code examples
htmlrstargazer

stargazer arima html dont't work


I am trying to use the stargazer package to create a beautiful output in r. But I run into the problem that it works for type = "latex" , but not in type = "html", throwing error Error in column.matrix [r, i]: subscript out of bounds. Any idea how to fix it.

---
title: "Untitled"
author: " "
date: "Sys.Date()"
output: html_document
---

```{r}
data("AirPassengers")
library(forecast)
fit <- auto.arima(AirPassengers)
```

```{r, results='asis'}
library(stargazer)
stargazer(fit)
fit2 <- arima(AirPassengers, order = c(2,1,1), seasonal = c(0,1,0))
stargazer(fit2, type = "latex")
stargazer(fit2, type = "html")
```
Error in column.matrix[r, i] : subscript out of bounds

Solution

  • I think it might be a problem in your first chunk of code carrying over to the second, perhaps introduced by library(forecast) which may be overwriting something that stargazer needs for the table. Also, I know that auto.arima is not supported in stargazer, only the stats::arima. My RMarkdown chunk was:

    ```{r, results='asis', warning=FALSE, message=FALSE}
    library(stargazer)
    fit2 <- stats::arima(AirPassengers, order = c(2,1,1), seasonal = c(0,1,0))
    stargazer(fit2, type = "html")
    ```
    

    And it produced this HTML:

    enter image description here