How To Make A PowerPoint Presentation Using R Markdown

Reading time:
time
min
By:
Dario Radečić
February 13, 2022

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. <blockquote><strong>Interested in a real-world use case? <a href="https://appsilon.com/gxp-compliance-in-pharma-made-easier-good-documentation-practices-with-r-markdown-and-officedown/" target="_blank" rel="noopener noreferrer">Here’s how we applied R Markdown in Pharma</a>.</strong></blockquote> Table of contents: <ul><li><a href="#getting-started">Getting Started</a></li><li><a href="#basics">What Can You Do With Markdown?</a></li><li><a href="#advanced">Images, Tables, and Custom Layout</a></li><li><a href="#style">How to Style Your R Markdown Presentation</a></li><li><a href="#conclusion">Conclusion</a></li></ul> <hr /> <h2 id="getting-started">R Markdown PowerPoint Presentation - Getting Started</h2> We assume you have R and RStudio installed. Once in RStudio, go to <em>File</em> - <em>New File</em> - <em>R Markdown</em>. A window like the one below should appear: <img class="size-full wp-image-12097" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01ee7832c47d67312b3e1_creating-new-r-markdown-powerpoint-presentaiton.webp" alt="Image 1 - Creating a new R Markdown PowerPoint Presentation" width="2564" height="1758" /> Image 1 - Creating a new R Markdown PowerPoint Presentation Give your presentation a title and optionally specify the author. Also, make sure to select <em>PowerPoint</em> 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: <img class="size-full wp-image-12099" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01ee892a26c843b62e764_Default-presentation-template.webp" alt="Image 2 - Default presentation template" width="2564" height="1758" /> Image 2 - Default presentation template That’s great, but how can you “compile” it? Well, easily! Click on the <strong>Knit dropdown</strong> and choose the <em>Knit to PowerPoint</em> option: <img class="size-full wp-image-12107" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01eea48b83fcd2e55b400_How-to-run-R-Markdown-PowerPoint-presentation.webp" alt="Image 3 - How to run R Markdown PowerPoint presentation" width="2564" height="1758" /> Image 3 - How to run R Markdown PowerPoint presentation That’s it! A PowerPoint presentation will be knitted and opened after a couple of seconds. Here’s what it looks like: <img class="size-full wp-image-12105" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01eea2a228de4b21e9ac2_First-rendered-presentation.gif" alt="Image 4 - First rendered presentation" width="1314" height="898" /> Image 4 - First rendered presentation 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. <h2 id="basics">What Can You Do With Markdown?</h2> 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: <ul><li><strong>Style the text</strong> - Use italics, bold, strikeout, subscript, superscript, small caps, and verbatim.</li><li><strong>Lists</strong> - Ordered and unordered.</li><li><strong>Links</strong> - Embed URLs to external websites.</li><li><strong>Quotes</strong> - Special indentation for your text.</li><li><strong>Equations</strong> - Does LaTeX ring a bell? You can use it in Markdown.</li></ul> 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: <script src="https://gist.github.com/darioappsilon/b2da95cfb87db52c2a49ba4ea3bb150a.js"></script> Your R Markdown file should look like this: <img class="size-full wp-image-12103" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01eeb6bb6e6a6629bfa2b_Exploring-Markdown-options.webp" alt="Image 5 - Exploring Markdown options" width="2564" height="1758" /> Image 5 - Exploring Markdown options And once again, use <em>Knit to PowerPoint</em> option to export the PPTX: <img class="size-full wp-image-12109" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01eec9506383404c4ec25_Rendered-markdown-presentation.gif" alt="Image 6 - Rendered markdown presentation" width="1314" height="898" /> Image 6 - Rendered markdown presentation 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. <blockquote><strong>Want to include your Bar Plots in your presentation? Follow these <a href="https://appsilon.com/data-visualization-best-practices-bar-plots/" target="_blank" rel="noopener noreferrer">Data Visualization Best Practices</a>.</strong></blockquote> <h2 id="advanced">Adding Images, Tables, and Custom Layouts to an R Markdown PowerPoint Presentation</h2> 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: <ul><li><strong>1st Slide</strong> - Loads a dog image from <a href="https://unsplash.com/photos/UinXDJCcqeY" target="_blank" rel="noopener noreferrer">Unsplash</a> and adds a caption to it.</li><li><strong>2nd Slide</strong> - Shows a table representing a subset from the <a href="https://gist.github.com/netj/8836201" target="_blank" rel="noopener noreferrer">Iris dataset</a>.</li><li><strong>3rd Slide</strong> - Implements a two-column layout.</li></ul> <script src="https://gist.github.com/darioappsilon/37a7b72b33753d95fa4553f0c968dd98.js"></script> This time, you won’t see any rendered output in the R Markdown file: <img class="size-full wp-image-12095" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01eed00b05468d71b8f4e_Adding-images-tables-and-custom-layouts.webp" alt="Image 7 - Adding images, tables, and custom layouts" width="2564" height="1758" /> Image 7 - Adding images, tables, and custom layouts Here’s what the final PPTX looks like: <img class="size-full wp-image-12111" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01eefe6755ca41b304f53_Rendered-Powerpoint-presentation.gif" alt="Image 8 - Rendered Powerpoint presentation" width="1314" height="898" /> Image 8 - Rendered Powerpoint presentation 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. <h2 id="style">How to Style Your R Markdown PowerPoint Presentation</h2> 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 (<em>View - Slide Master</em>). Once inside, tweak it as you normally would when styling a PPTX file. <blockquote><strong>Excel is good, but not great. Check out our <a href="https://appsilon.com/excel-is-obsolete-here-are-the-top-2-alternatives-from-r-and-python/" target="_blank" rel="noopener noreferrer">top alternatives from R and Python</a>. </strong></blockquote> We’ll only change the theme, just to keep things simple: <img class="size-full wp-image-12101" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01ef20a2ba062e1ba27da_Editing-the-slide-master.webp" alt="Image 9 - Editing the slide master" width="3100" height="2024" /> Image 9 - Editing the slide master You’re free to take your time here and add custom graphics, fonts, and other visual elements. Once done, <strong>save the PPTX file right where your .Rmd file is</strong>: <img class="size-full wp-image-12115" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01ef40fc7bbb4c493e2d2_Saving-PowerPoint-template.webp" alt="Image 10 - Saving PowerPoint template" width="3424" height="2024" /> Image 10 - Saving PowerPoint template 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: <script src="https://gist.github.com/darioappsilon/f1b601dd3efaf3faa2e21ea06cf9c475.js"></script> 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: <img class="size-full wp-image-12113" src="https://webflow-prod-assets.s3.amazonaws.com/6525256482c9e9a06c7a9d3c%2F65b01ef4385c8d506b9c0ed3_Rendered-presentation-with-a-custom-template.gif" alt="Image 11 - Rendered presentation with a custom template" width="1314" height="898" /> Image 11 - Rendered presentation with a custom template 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. <h2 id="conclusion">Conclusion</h2> 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: <ul><li>Try to embed a YouTube video or a GIF. Is there any difference from regular images?</li><li>Add presenter notes to one or more slides.</li><li>Try to add animations between slides. Is it possible?</li></ul> Feel free to share results with us on Twitter – <a href="https://twitter.com/appsilon" target="_blank" rel="noopener noreferrer">@appsilon</a>. We’d love to see what you come up with. <blockquote><strong>R isn’t limited to Markdown only. <a href="https://appsilon.com/best-r-shiny-books-and-courses/" target="_blank" rel="noopener noreferrer">Here are the top free resources if you want to learn R Shiny</a>.</strong></blockquote>

Have questions or insights?

Engage with experts, share ideas and take your data journey to the next level!

Is Your Software GxP Compliant?

Download a checklist designed for clinical managers in data departments to make sure that software meets requirements for FDA and EMA submissions.
Explore Possibilities

Share Your Data Goals with Us

From advanced analytics to platform development and pharma consulting, we craft solutions tailored to your needs.

Talk to our Experts
r
r community
tutorials