How To Make A PowerPoint Presentation Using R Markdown
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
PowerPoint is the most recognized presentation-making software, but it isn’t for everyone. Some may find it packed with unnecessary features, and to some extent that’s true. Microsoft updates it regularly and invents things you never even knew you needed.
If you’re a programmer at heart, you likely value simplicity. That’s where this article comes in. We’ll ditch PowerPoint and make presentations in a way you didn’t know was possible. After reading, you’ll know how to make an entire editable PowerPoint presentation using only R Markdown.
Interested in a real-world use case? Here’s how we applied R Markdown in Pharma.
Table of contents:
- Getting Started
- What Can You Do With Markdown?
- Images, Tables, and Custom Layout
- How to Style Your R Markdown Presentation
- Conclusion
R Markdown PowerPoint Presentation – Getting Started
We assume you have R and RStudio installed. Once in RStudio, go to File – New File – R Markdown. A window like the one below should appear:
Give your presentation a title and optionally specify the author. Also, make sure to select PowerPoint as the default output format. R will ask you to install a couple of dependencies if this is your first time working with R Markdown. After clicking on OK you’ll see a default R Markdown PowerPoint presentation code:
That’s great, but how can you “compile” it? Well, easily! Click on the Knit dropdown and choose the Knit to PowerPoint option:
That’s it! A PowerPoint presentation will be knitted and opened after a couple of seconds. Here’s what it looks like:
It’s a strong start but definitely needs work. I’ll show you how to spice it up in the sections below. First, we’ll explore what can you actually do with Markdown.
What Can You Do With Markdown?
Markdown is a free-to-use markup language used to format plain text. It’s popular among developers and technical writers because it provides you with everything you need and nothing else. We’ll now explore what can you do with R Markdown, and how you can do it. You’ll learn how to:
- Style the text – Use italics, bold, strikeout, subscript, superscript, small caps, and verbatim.
- Lists – Ordered and unordered.
- Links – Embed URLs to external websites.
- Quotes – Special indentation for your text.
- Equations – Does LaTeX ring a bell? You can use it in Markdown.
We’ll also cover more advanced Markdown functionality, but these are enough for one section. Use the following code to declare two slides with all mentioned Markdown functionalities:
Your R Markdown file should look like this:
And once again, use Knit to PowerPoint option to export the PPTX:
The R Markdown PowerPoint presentation still looks rough around the edges, but we’ll address the visuals soon. Before we do that, let’s go over a couple of “advanced” Markdown elements, and how to get the most out of them.
Want to include your Bar Plots in your presentation? Follow these Data Visualization Best Practices.
Adding Images, Tables, and Custom Layouts to an R Markdown PowerPoint Presentation
A presentation without images and tables is, well, boring. Also, most presentations make use of multiple layouts. For example, there are scenarios where a two-column layout is preferred. You’ll learn how to use it in this section.
The code snippet below implements the following:
- 1st Slide – Loads a dog image from Unsplash and adds a caption to it.
- 2nd Slide – Shows a table representing a subset from the Iris dataset.
- 3rd Slide – Implements a two-column layout.
This time, you won’t see any rendered output in the R Markdown file:
Here’s what the final PPTX looks like:
You now know the basics of R Markdown – just enough to place any type of content into your R Markdown PowerPoint presentations. But how can you make the slideshow visually appealing? That’s what we’ll explore next.
How to Style Your R Markdown PowerPoint Presentation
The default PPTX layout is, well, default, and doesn’t look attractive at all. To change it, you’ll first have to create a blank PowerPoint presentation and open the Slide Master (View – Slide Master). Once inside, tweak it as you normally would when styling a PPTX file.
Excel is good, but not great. Check out our top alternatives from R and Python.
We’ll only change the theme, just to keep things simple:
You’re free to take your time here, add custom graphics, fonts, and other visual elements. Once done, save the PPTX file right where your .Rmd file is:
You can save it elsewhere, but it’s a good practice to keep the PowerPoint template and R Markdown file in the same directory.
To use the template, you’ll only have to modify the header of the R Markdown file:
That’s why we saved the PPTX template in the same directory. There’s no need to think about the path. Everything else in the Rmd file remains the same.
Knit the PowerPoint presentation to verify the template was used:
And would you look at that – a custom PowerPoint template was successfully applied to our R Markdown PowerPoint presentation. We won’t dive into more advanced use cases today, as this alone is enough to cover what most programmers and tech users need. But if you’d like to learn about more advanced uses, let us know.
Conclusion
PowerPoint isn’t for everyone, just like MS Word. If you know Markdown, you can write and edit text documents much faster than in a traditional word processor. What makes things even better is its shareability, as most online writing platforms understand Markdown.
R Markdown is by no means a replacement for dedicated office suites, so keep that in mind. It might be a decent alternative if you need to automate slide production, simply don’t want to use PowerPoint, or if you don’t need all the functionalities it offers.
To further drive the point home, we recommend the following homework tasks:
- Try to embed a YouTube video or a GIF. Is there any difference from regular images?
- Add presenter notes to one or more slides.
- Try to add animations between slides. Is it possible?
Feel free to share results with us on Twitter – @appsilon. We’d love to see what you come up with.
R isn’t limited to Markdown only. Here are the top free resources if you want to learn R Shiny.
Article How To Make A PowerPoint Presentation Using R Markdown comes from Appsilon | Enterprise R Shiny Dashboards.
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.