dcomtois / summarytools

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

Suggestion : add some <br> in the view(dfSummary(data),method = "render") #55

Closed cecilesauder closed 5 years ago

cecilesauder commented 5 years ago

When I run view(dfSummary(data)) in the console I get something like this

2018-12-14 11_03_08-data frame summary

but when I put view(dfSummary(data), method = "render") in my Rmd (html_output) , I get this :

2018-12-14 11_03_44-rapport sur dig reporting de decembre

I think adding some <br> at the end each lines in Stats / Values and Freqs to have the same result that in the Rstudio Viewer could be very good :)

Thanks for your package !

dcomtois commented 5 years ago

Hi Cecile, thanks for your feedback. This has to do with css... Check out the following vignette which gives working examples:

https://cran.r-project.org/web/packages/summarytools/vignettes/Recommendations-rmarkdown.html

The line feeds are there (we can't put <br>'s inside a table cell per html specifications), there just needs to be a style element to tell the browser not to ignore them... Specifically, this is how summarytools does it: it includes this "chunk" in its css file (summarytools.css):

.st-multiline {
  white-space: pre;
}

... and the class "st-multiline" is given to dfSummary tables. If you look at the source html after for instance print(dfSummary(iris), file = "~/test.html"), you'll see it.

See the vignette and this link for another explanation: https://stackoverflow.com/questions/10937218/how-to-show-multiline-text-in-a-table-cell

... and let me know how this goes!

Edit: I realize this can be tedious... I'll explore an avenue using the <pre> tag as discussed in the Stack Overflow post, and I'll keep everyone posted.

cecilesauder commented 5 years ago

Hi Dominic, I solve the problem with what you specified in the vignette, I add the summarytools.css file in the yaml and now it's work ! Thanks for your help :) This problem was with the CRAN version of the package because with the dev-current version I couldn't render my . Rmd. I'm going to try again you new dev-current version today.