dcomtois / summarytools

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

dfSummary does not show correct table in rendered html #108

Closed ryamy closed 4 years ago

ryamy commented 4 years ago

Here is my code.

dat <- tbl_df(diamonds)
view(dfSummary(dat))

this shows expected figures in generated html.

but I 'd like to embed those to my rmarkdown htmldocument, so I coded as like bellow;

dfSummary(dat, plain.ascii=FALSE, style='grid', graph.magnif=0.75,
          valid.col=FALSE, tmp.img.dir='tmpc')

but this does not works in rmarkdow rendered documents and results is bellow; rendered html

I wondered why all of my r command output is commented out by ## in rendered html, and assume this cause dfSummary output breaking.

How can I fix this issue? Do you have any ideas??

bellow is my emvironments:

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] readr_1.3.1         summarytools_0.9.6  papeR_1.0-4        
 [4] xtable_1.8-4        car_3.0-7           carData_3.0-3      
 [7] RColorBrewer_1.1-2  viridisLite_0.3.0   formattable_0.2.0.1
[10] ranger_0.12.1       kableExtra_1.1.0    reticulate_1.14    
[13] yardstick_0.0.6     workflows_0.1.1     tune_0.0.1         
[16] tibble_2.1.3        rsample_0.0.5       recipes_0.1.10     
[19] purrr_0.3.3         parsnip_0.0.5       infer_0.5.1        
[22] dials_0.0.4         scales_1.0.0        broom_0.5.5        
[25] tidymodels_0.1.0    rmarkdown_2.1       knitr_1.28         
[28] tidyr_1.0.0         dplyr_0.8.5         ggplot2_3.2.1      

Thanks!

serghiou commented 4 years ago

Did you set your chunk's options to {r, results='asis'} ? If you did and it still did not work, try printing, i.e.

print(dfSummary(dat, plain.ascii=FALSE, style='grid', graph.magnif=0.75,
          valid.col=FALSE, tmp.img.dir='tmpc'))
ryamy commented 4 years ago

Thanks, {r results='asis'} fixed the issue! This specified in vignette, I had to check that. Thanks a lot for your quick answer!

serghiou commented 4 years ago

You are welcome!