问题
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