A workflow with bookdown to produce frequency, cross tables and model summary tables

无人久伴 提交于 2020-01-03 03:32:10

问题


I am starting to write a book using bookdown and trying to find the best workflow. First of all I am trying to make frequency tables, crosstables and model summaries, using bookdown with pdf format mainly, but I am pretty sure my advisor will love I send word documents for revision, so also getting a word output would be awesome. Word output can be achieved producing first the .html file and then opening with Word. So .html and .pdf output at the same time are desiderables.

Tables are the main problem because seems impossible to find a productive way to produce frequency, crosstable and summarymodels without too excessive pain in both formats at the same time. Using knitr has an added value since it and kableExtra provide a set of customizations.

So far I've tried:

1) sjmisc / sjPlot with the frq / sjt.frq (deprecated) function but only provides html objects as it is said in the comments of this post, also has the lack of labels for cross reference in the document.

2) stargazer package but doesn't have frequency tables available and .pdf and .html output at the same time seems impossible to achieve. However summary models are pretty good!

3) descr package with the freq function used inside kable:

f <- descr::freq(iris$Species, plot = F)
kableExtra::kable(data.frame(f), caption = "Foo") 

However crosstab output cant be coerced to data.frame while using crosstab function.

Any ideas?

Thanks in advance!


回答1:


https://haozhu233.github.io/kableExtra/bookdown/index.html

https://github.com/haozhu233/kableExtra/tree/master/docs/bookdown_example

Check out this sample document (I'm still working on this document recently so you may expect some change). Note that you might need the latest dev version of kableExtra and bookdown for some of the formatting features mentioned there.



来源:https://stackoverflow.com/questions/52697709/a-workflow-with-bookdown-to-produce-frequency-cross-tables-and-model-summary-ta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!