Make Microsoft Word Reports with R + officedown

[This article was first published on business-science.io, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

What’s the one thing that will impress your company (that you can make in under 60 minutes)? A professional business report.

And Microsoft Word is the defacto standard (NOT Jupyter Notebooks or HTML web-reports). Even PDFs aren’t ideal, especially if they need to review and comment on them.

Table of Contents

Today I’m going to show you how to make professional Microsoft Word Reports use officedown. Here’s what you’re learning today:

  • Tutorial: How to use officedown to effortlessly produce a Microsoft Word Report (that your company will read)
  • Bonus: Get a Free Rmarkdown Template for making Word Reports

Microsoft Word Report Made with R

R-Tips Weekly

This article is part of R-Tips Weekly, a weekly video tutorial that shows you step-by-step how to do common R coding tasks. Pretty cool, right?

Here are the links to get set up. 👇

This Tutorial is Available in Video

I have a companion video tutorial that gives you the bonus Rmarkdown MS Word Template shown in this video (plus walks you through how to use it). And, I’m finding that a lot of my students prefer the dialogue that goes along with coding. So check out this video to see me running the code in this tutorial. 👇

Why Making Microsoft Word Reports from R is a Must

Listen, there’s one way to immediately turn off an executive…

And that’s by giving them a Jupter Notebook (I mean look at this mess).

Don't Use Jupyter for Executives

Please don’t send Executives reports that look like this.

Nothing against those that use Jupyter Notebooks to make their analysis.

But, if you sent one of those to me (and I’m an executive that’s used to reading reports in Microsoft Office formats like Excel and Word)…

…Then I’m going to immediately hit my Email Trash Icon (and probably not tell you.)

How does that make you feel?

You just spent days on a report. And guess what, it’s not getting read.

Well let’s fix that by learning how to making Microsoft Word Reports today.

Thank You to the Developer (and Community).

Before we do our deep-dive into officedown, I want to take a brief moment to thank the developer, David Gohel. David runs a consulting company Ardata. Please connect and follow David. His work is on GitHub here.

Also I’d like to thank Adrian Olszewski, Principal Biostatistician at 2KMM for sharing the Office-verse R ecosystem with me. Without community and sharing knowledge, this R-tip wouldn’t be possible.

Free Gift: Cheat Sheet for my Top 100 R Packages (Special Data Analysis Topics Included)

Before we dive in…

You’re going to need R packages to complete the analysis that goes in your MS Word reports. So why not speed up the process?

To help, I’m going to share my secret weapon…

Even I forget which R packages to use from time to time. And this cheat sheet saves me so much time. Instead of googling to filter through 20,000 R packages to find a needle in a haystack. I keep my cheat sheet handy so I know which to use and when to use them. Seriously. This cheat sheet is my bible.

Ultimate R Cheat Sheet

Once you download it, head over to page 3 and you’ll see several R packages I use frequently just for Data Analysis.

Cheat Sheet Page 3 Special Topics

Which is important when you want to work in these fields:

  • Machine Learning
  • Time Series
  • Financial Analysis
  • Geospatial Analysis
  • Text Analysis and NLP
  • Shiny Web App Development

So steal my cheat sheet. It will save you a ton of time.

Tutorial: Make Microsoft Word Reports with officedown

Here’s how to use officedown to start make a professional Word Report.

Step 1: Make an Rmarkdown document

Start by making a normal Rmarkdown document. Go to File > New File > R Markdown.

Make RMD File

Step 2: Enable Officedown

Enable officedown as the Rmarkdown Output.

Enable Officedown

Get the code.

Step 3: Setup the document’s global knitr options

Use these knitr options to let officedown format the table and figure captions.

Global Knitr Options Officedown

Get the code.

Step 4: Add Table of Contents

The block_toc() function allows the Word Table of Contents to be generated.

Table of Contents Officedown

Get the code.

Here’s what the Table of Contents looks like.

Table of Contents Officedown Word

Step 5: Add Figures

This is where you start building the core of your report. Officedown integrates:

  • Hyperlinked Figure Captioning using \@ref(fig:fig_id)
  • Knitr Options like fig.id to connect the linked references to the figures
  • Just add R Code inside of the Rmarkdown chunks like you would normally

Add Figures Officedown

Get the code.

Here’s what it looks like in the report:

Figures Word Doc Officedown

Step 5: Add Tables

The last step is adding tables in your document.

Tables Word Doc Officedown

Get the code.

And here’s what it looks like in the Word Report.

Tables Word Doc Officedown

Step 6: Knit the Report

The last step is to click the “knit” button.

Knit Word Doc Officedown

Get the code.

Viola! You get a professional report:

Microsoft Word Report Made with R

Bonus: Steal My Officedown Template

Want to speed up the process? You can steal my Officedown Template. All you need to do is subscribe to my R-Tips Newsletter.

Officedown Template

Steal My Officedown MS Word Template.

Once you register, you’ll get instructions to download all of the R-Tips.

The Officedown Word Template is located in the folder 058_ms_word_reports.

💡 Conclusions

You learned how to use the officedown library to create a professional-looking Microsoft Word Report. Great work! But, there’s a lot more to becoming a data scientist.

If you’d like to become a Business Data Scientist (and have an awesome career, improve your quality of life, enjoy your job, and all the fun that comes along), then I can help with that.

My Struggles with Learning Data Science

It took me a long time to learn how to apply data science to business. And I made a lot of mistakes as I fumbled through learning R.

I specifically had a tough time navigating the ever-increasing landscape of tools and packages, trying to pick between R and Python, and getting lost along the way.

If you feel like this, you’re not alone.

In fact, that’s the driving reason that I created Business Science and Business Science University (You can read about my personal journey here).

What I found out is that:

  1. Data Science does not have to be difficult, it just has to be taught from a business perspective
  2. Anyone can learn data science fast provided they are motivated.

How I can help

If you are interested in learning R and the ecosystem of tools at a deeper level, then I have a streamlined program that will get you past your struggles and improve your career in the process.

It’s my 5-Course R-Track System. It’s an integrated system containing 5 courses that work together on a learning path. Through 8 projects, you learn everything you need to help your organization: from data science foundations, to advanced machine learning, to web applications and deployment.

The result is that you break through previous struggles, learning from my experience & our community of 2653 data scientists that are ready to help you succeed.

Ready to take the next step? Then let’s get started.

Join My 5-Course R-Track Program
(Become A 6-Figure Data Scientist)

To leave a comment for the author, please follow the link and comment on their blog: business-science.io.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)