dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data
512 stars 77 forks source link

Strange output for Label column of dfSummary for version 0.9.1 and later #82

Closed iago-pssjd closed 5 years ago

iago-pssjd commented 5 years ago

For version 0.9.1 and later of summarytools and the Rmarkdown code

---
title: "test"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(comment=NA, prompt=FALSE, echo = TRUE, cache=F, tidy= T, results='asis')
library(summarytools)
library(sjlabelled)
data(efc)
st_options(plain.ascii = FALSE,
           style = "rmarkdown",
           dfSummary.varnumbers = FALSE,
           dfSummary.valid.col = FALSE)    # (I used this instruction only for version 0.9.1)
print(dfSummary(efc,  omit.headings = T), method = 'render')

I get the output
![dfSummary091](https://user-images.githubusercontent.com/40892925/64178301-8466f400-ce61-11e9-8c1b-16cb9e1caee2.png)
(`Label` title of corresponding column unformatted)
Meanwhile, for version 0.8.8 output was correct (`Label` title printed as other column titles).
![dfSummary088](https://user-images.githubusercontent.com/40892925/64178521-e889b800-ce61-11e9-954d-e0bab30a867d.png)

If I include function `st_css()`, output does not get much better.
dcomtois commented 5 years ago

I found the cause and updated the master branch. Could you pls try after re-installing with: devtools::install_github("dcomtois/summarytools")

For using st_css(), it must be in an echo=FALSE chunk. So this should produce adequate results:


---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(results='asis')
suppressPackageStartupMessages(library(summarytools))
st_css()
st_options(plain.ascii = FALSE,
           dfSummary.varnumbers = FALSE,
           dfSummary.valid.col = FALSE,
           dfSummary.style = "grid")
label(iris$Sepal.Length) <- "Some label"
print(dfSummary(iris, headings = FALSE, silent = TRUE), method = 'render')
iago-pssjd commented 5 years ago

Thanks! I tested that code and also my original one and they work.