I have been using officedown for some time now to knit to docx. I encountered an issue where a table I had to create required superscripts in the table as shown below
This led me to go over all the methods for creating a table. Rather than typing it all out here I created an Rmd document below which goes through all the issues. I would be interested in knowing if anyone has any comments or suggestions. My goal is simple. We want a table that exports to docx that
Shows up in the list of tables
Has a caption
In-text reference
Shows the fractions correctly
Please find the detailed Rmd with examples HERE
I apologize for the length of the Rmd document but I wanted to showcase in detail what I have attempted to do to facilitate answers and suggestions
Update: Got a little roasted on the officer GitHub but it seems that fractions are not possible at the moment but subscripts are using ftExtra
Related
I really need help this time:
Rstudio auto-install some babel-stuff after I've indicate the language of an academic paper in YAML (lang: "fr-FR"). After that point, when I'm knit to pdf, tables and figures doesn't render anymore in the pdf: computation printed in the text are correct, but the pdf produced is now without figure, without table, and cross-references are not working anymore (e.g., the pdf now contain some "Figure #ref(tab:repartition-transport)" where before the language-change there is a number printed like "Figure 1").
I try to set language back to "en-EN" but cross-references, tables and figures doesn't render in the pdf.
The error message said that, when knitting is over:
Package babel Warning: No hyphenation patterns were preloaded for the language 'French' into the format.
Avis : (babel) Please, configure your TeX system to add them and rebuild the format.
Now I will use the patterns preloaded for \language=nohyphenation instead on input line 87.
I don't understand.
Since I don't know how to remove babel (which is not in the packages list), I try to run tinytex::check_installed("babel"), which answer: TRUE. Any help is very appreciated, since I don't know what is the problem.
Thanks
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!
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.
I'm using Rmarkdown/Bookdown to write a paper/PDF document, which is an amazing tool #Yihui, thanks! Now I'm trying to include a table I have already put in LaTeX into the document by reading in this external .tex file. However, when knitting in RStudio with a \include{some-file.tex} or input{some-file.tex} in the body of the .Rmd outside of a chunk a LaTeX Error: Can be used only in preamble. is produced and the process stopped. I haven't found a way how to directly input through knit or otherwise into a chunk as well.
I found this question here: Rmarkdown v2, embed Latex document, although while the question is similar, there is no answer which would reflect how to input/include .tex-files into an .Rmd.
Why would I want this? Sometimes LaTeX tables offer more layout options than building directly in R, like for tables only with text rather than R-computed numbers. Also, when running models on a cluster, exporting results directly into .tex ready for compilation saves a lot of computation compared to have to open all these heavy .RData files just for getting the results into a PDF. Similarly, having sometimes multiple types of reports with different audiences, having the full R code in one main .Rmd file and integrating only the necessary results in other files reduces complexity by not having to redo all steps in each file newly. This way, I can keep one report with the full picture and do not have to check if I included every little change in various documents simultaneously.
So finally the question is how to get prepared .tex-Files into a .Rmd-document?
Thanks for your answers!
I'm creating some RMarkdown reports and want to be able to extensively format a table. I've tried working with kable and pander but they don't give me enough functionality (for example to use colors for rows).
I ran across the Rtable package (that goes along with the FlexTable object of the Reporters package) which allows significant customization. The only problem is that I can so far only get my table to show up when I knit to html, when I knit to pdf (what I need) I just get an unformatted list of text instead of my table.
here's what my code looks like (summaryterms is a dataframe)
setZebraStyle(FlexTable(summaryterms[c(5,1:3,9:11,14)]),odd = "#DDDDDD", even = "#FFFFFF" )
Is there anyway to use the FlexTable object with a pdf report?
Thank you so much for the help
Also, I'm open to any and all other solutions to format tables in rmarkdown, I'm not married to using flextable.
I've been struggling with this for a while and I was hoping someone might be able to help me out. I'm using Rmarkdown and Knitr in RStudio to produce a word document (.docx), which I am populating with data. The only issue is no matter what I do, I can't seem to create consistent column widths. I've tried using a reference .docx, with no luck, and I've tried using pandoc.table with "split.cells", which changes the result printed to R console, but the formatting goes away when Knitr puts it into word:
panderOptions("table.split.cells",c(10,1,10,1,1))
pandoc.table(function_to_create_table(x))
Any suggestions? I feel like there's an obvious answer that's been eluding me.