Skip to content
R for the Rest of Us Logo

How to generate QR codes in R

Ever given a presentation and wanted an easy way for people to access your materials afterwards? I recently discovered a neat solution: adding QR codes to slides! In my recent posit::conf() talk, I used QR codes to help people quickly access my slides, GitHub repo, and website – no need for anyone to frantically type in long URLs.

I've made a quick R in 2 Minutes video showing how to use the qrcode package in R to automatically generate these QR codes. Here's what I cover:

  • Using the qr_code() function to generate QR codes

  • Saving the QR codes as SVG files with generate_svg()

  • Adding the QR codes to your Quarto slides

Here's the code that I used:

library(qrcode)

qr_code("https://rfor.us/posit2024slides") |>
  generate_svg(
    "assets/qrcode-slides.svg",
    background = "transparent",
    show = FALSE
  )

qr_code("https://rfor.us/posit2024repo") |>
  generate_svg(
    "assets/qrcode-repo.svg",
    background = "transparent",
    show = FALSE
  )

qr_code("https://rfor.us/consulting") |>
  generate_svg(
    "assets/qrcode-consulting.svg",
    background = "transparent",
    show = FALSE
  )

Sign up for the newsletter

Get blog posts like this delivered straight to your inbox.

Let us know what you think by adding a comment below.

You need to be signed-in to comment on this post. Login.

David Keyes
By David Keyes
January 23, 2025

Sign up for the newsletter

R tips and tricks straight to your inbox.