Skip to content
R for the Rest of Us Logo

Making Your Reports Shine: Word Edition

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

Use a reference document to change the look and feel of your report when knitted to Word

Learn More

Daniel Hadley talks about using reference documents to brand RMarkdown reports in this video from rstudio::conf 2018.

Richard Layton also has an article on reference documents on the RStudio website.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Abby Isaacson

Abby Isaacson

June 10, 2021

FYI, I got an error when trying the word default, saying: Error: Functions that produce HTML output found in document targeting docx output. Please change the output type of this document to HTML. Alternatively, you can allow HTML output in non-HTML formats by adding this option to the YAML front-matter of your rmarkdown file:

always_allow_html: true

Note however that the HTML output will not be visible in non-HTML formats.

So I had to add the recommended line before the output (after did not work): title: "Who's Getting Vaccinated for Measles in U.S. Schools?" author: "Abby Isaacson" date: "3/22/2021" always_allow_html: true output: word_document: default html_document: toc: TRUE number_sections: FALSE

This yielded the default Word doc, however my second question (which has been true for your paged report templates as well): The leaflet map I created in the last section has disappeared. When I knit to PDF, the map is still there just not interactive. With paged report or Word, it's just gone. Any tips?

JULIO VERA DE LEON

JULIO VERA DE LEON

May 10, 2022

Hi! Is it possible to apply themes to a table and make it appear with that theme in Word?

Chris Matthis

Chris Matthis

May 26, 2022

I think the solution video and the main video are the same 53 second clip. Should the main one be different and introduce the template building? Thanks!

Sara Cifuentes

Sara Cifuentes

June 9, 2022

Hello, I have created a template document. However, when I knit it, I do not receive any error, and the word document maintains the default appearance without changes.

output: word_document: reference_docx: template.docx html_document: toc: TRUE toc_depth: 2 toc_float: TRUE

Andrew Paquin

Andrew Paquin

May 30, 2023

Hi David, I ran into a bit of trouble. Parts of my chosen template document have come over to my report, but not all. I've described what I see in the video linked below. Any ideas? https://www.loom.com/share/017e9dbe8597432d92e7554f1f9207f4