dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data
523 stars 78 forks source link

transpose does not show rownames if huxtable package is loaded #151

Closed bjornerstedt closed 2 years ago

bjornerstedt commented 3 years ago

The following example Rmarkdown is intended to show a rendering problem with transposed stats when both huxtable and summarytools packages are loaded.

```{r}
library(knitr) 
library(summarytools)
st_options(plain.ascii = FALSE, style = "rmarkdown")
```

The following chunk displays rownames (variable names)

```{r, results='asis'}
descr(iris, stats = "common", transpose = TRUE)
```

Loading huxtable displays as table without row headings. The same error occurs if huxtable is loaded before summarytools

```{r, results='asis'}
library(huxtable) 
descr(iris, stats = "common", transpose = TRUE)
```

Rendering with kable works

```{r}
kable(descr(iris, stats = "common", transpose = TRUE) )
```

I am using summarytools 1.0.0 and pander version 0.6.5. Huxtable is version 5.4.0

dcomtois commented 2 years ago

Thx for reporting this... unfortunately I haven't had time to look into most issues for a while, hopefully some other developers can help out at some point.

iago-pssjd commented 2 years ago

@bjornerstedt @dcomtois

This happens in R markdown documents because the output of descr(iris, stats = "common", transpose = TRUE) has class "summarytools" "data.frame", and while not loading huxtable, knitr prints this object through knitr:::knit_print.default (there is no knit_print method for any of the 2 classes of the descr output), when huxtable is loaded, the output is printed through the S3 method huxtable:::knit_print.data.frame.

Then, I do not think this is actually a summarytools issue.

dcomtois commented 2 years ago

Thanks @iago-pssjd , I think you've got this figured out... I'll add a "known issues" section in the docs and mention this,