write_slides()
If you would like to produce a slide deck, and optionally include the
slides in an R package, rUM
can help you. The
write_slides()
function will give you a folder that
contains a slide template, which will render a Quarto (reveal.js) slide
deck, along with a couple configuration files. If you have used R
Markdown or Quarto to write papers, writing slides will be simple for
you. The write_slides()
function takes care of the
configuration of the title slide and sets the details you need in a YAML
header. You can add slides using the syntax you already know - a line
that starts with #
will make a “section heading” slide and
##
makes a slide with a title at the top of the page. The
rest is the same old R Markdown and Quarto magic you already know
augmented to give you control of things like slide transitions and
animations. To learn how to make beautiful slides take a look here.
The write_slides()
function also provides an example of
a complex template, the slide deck for the R Medicine 2025 conference,
which features details like a image on the title page, custom coloring,
details on where viewers can find your slides, and custom logos. To make
a fancy slide deck, all you need to do is swap out a few image files and
specify your content.
To create a slide deck write code like this:
rUM::write_slides(filenames = "slide_demo", path = "~/Desktop/")
You will get a folder called slides that contains three files.
When you use the template = "rmed2025"
argument to
write_slides()
you get a folder called img
in the slides folder. For example, you could type:
rUM::write_slides(
filenames = "slide_demo",
path = "~/Desktop/",
template = "rmed2025"
)
It contains a html file you don’t want to touch and a few image files that you will replace with your own files.
Open the img folder to see the image files and open the .qmd file and look at the YAML header. There are a couple files and lines of code you will want to tweak.
data-background-image: "img/rmed_background.png"
logo: "img/rmed.png"
footer: "[Slides are here](https://){target='_blank'}" # complete the URL
<link rel="shortcut icon" href="img/rmed.ico"/>
If you would like to add a slide deck to project that will build into an R package, first make a project with the necessary package details (take a look at the Make a Package vignette). Then come up with a name for your slide deck (here I am calling it final_results). Finally, request that the slides are saved in a slides subfolder in the inst folder like this:
# write into the inst/slides/ folder
rUM::write_slides("final_results", path = "./inst")
People will be able to access your slides using the
find_slides()
and show_slides()
functions.
Take a look at the Find and Show
Slides in a Package vignette to learn about those functions.