24  Making slides for presentations

Since data visualization is ultimately about communication, you will often need to talk to people about what you’ve learned. In this lesson I’ll provide some suggestions on how to make a good presentation about a data visualization or analysis. I’ll show you how to use R markdown and Rstudio to make visual aids for your presentation.

24.1 What makes a good presentation?

A good presentation tells a story that engages your audience, has a clear purpose advanced through a predictable arc from introduction through evidence to a conclusion. There are many ways to design a good presentation, but most people find that practice and reflection on what works for your own personal goals and audience are a key part of the trajectory.

24.2 Why we make slides

Visual aides, commonly called slides, can help you communicate with your audience. Computer software makes it easy to generate lots of slides full of text that the presenter reads. This is generally a bad approach as the audience’s attention is focused more on reading than listening and as a result they tend to be less engaged with your presentation. There are, of course, many different opinions on this topic!

In data visualization, we make slides to display the visualization! That’s the primary reason for the slide, so your slides should focus on the visualization. The visualization should be large enough to be seen by everyone watching. This is much easier when everyone watches a presentation by teleconferencing. In a classroom, when the slide is far away, you must be careful not to put too much on a slide and not to make any element of the slide too small.

24.3 How to make slides using Rstudio

There are several packages to help you make slides with R markdown. The method we will use is well integrated into Rstudio. To create a presentation, select the menu File > New File > Quarto Presentation.1 You will be asked to provide a title for your presentation and there are a few options, but you don’t need to change any of them. This will give you a sample file with a title slide. The R markdown tools you already know for text formatting, list making, and titles all work here. Of course, you can insert R code blocks and have the output included as well. All of this is described in the help available from the menu Help > Markdown quick reference.

  • 1 You need to have a version of Rstudio from the July 2022 or newer for this to work. If your copy of Rstudio doesn’t have this menu item, this is a good time to update!

  • The top of your slide file should have five lines: a row with three minus signs, a title, an author, and a format line, followed by three minus signs by themselves on a line. Use format revealjs:

    ---
    title: "Practice slides"
    author: "Andrew Irwin"
    format: revealjs
    ---

    The most important new idea is how to start a new slide. It’s simple. Create a level one or two heading (one or two hash marks at the start of a line, followed a space, then a short title) or write three minus signs at the start of a blank line. A level one heading is the largest and it is centered vertically on the slide. A level 2 heading appears at the top of a slide. If you start a new slide with three minus signs, there is no title. That’s handy if you want to make as much room as possible for a graph or image.

    The Quarto website has excellent documentation on the basics and more specialized formatting for making slides. In this lesson I’ll give you just enough information to get started.

    24.4 Formatting tricks

    24.4.1 Hiding code

    Usually in a presenation you don’t want to show your computer code – its too complex to be easily digested by the audience. (This course, is naturally, a bit of an exception!) You can hide output by writing the start of your code block like this:

    {r echo=FALSE}

    The main options for showing code, the results of code, warning messages, and errors are summarized here. The option fig.cap="Message" is particularly useful for adding text. (The options are: echo, eval, include, warning, message, which can all be TRUE or FALSE.)

    If you want to hide the code, but make it possible to see it after a click, you can “fold” the code so it’s not visible by adding two special comments inside your R code block:

    #| code-fold: true
    #| code-summary: "Show the code"

    Try it out to see what happens.

    24.5 Changing the size and position of a plot

    The following code chunk options let you control the size and position of a plot:

    • out.width = "70%" (or other value, in quotation marks)
    • fig.align = "center" (or left, right)

    For more figure formatting options look here

    24.6 Two column formatting

    If you want to divide your slide into a left and right column, split your material between sections marked off with three colons (:::) as follows:

    :::: {.columns}
    
    ::: {.column width="40%"}
    Left column
    :::
    
    ::: {.column width="60%"}
    Right column
    :::
    
    ::::

    You can adjust the amount of space used by each side by changing the percentages. You can have more than two columns if you like too—but your slide will get crowded and the columns get narrow.

    24.7 What if my material won’t fit on a single slide?

    If you try to put too much on a slide, there just isn’t room and it disappears off the bottom. Usually the right decision is to split your material across two slides.

    But you have other options. After the title you can add an instruction to make everything on the slide smaller. For example write a title as

    ## Slide title {.smaller}

    If the material still doesn’t fit, you can make the slide scrollable using

    ## Slide title {.scrollable}

    but remember, when you show the slide you’ll have to scroll to let viewers see the material off the bottom. This might work best with slides you distribute so that the viewer can scroll by themselves. In a live presentation, scrolling like this could be quite disorienting!

    24.8 Summary

    This was an introduction to making slides with R. I’ve picked a method which is relatively easy to use and is well integrated with Rstudio.

    24.9 Exercise

    Make a slide presentation with a few slides. Click “Render” (instead of knit) to see your slides. The slide presentation is just a regular html file, so you can open it in a web browser.

    24.10 Further reading