Tool
R
Python
Author

Tony D

Published

March 16, 2025

Making QR code with R and Python

R

Code
pak::pkg_install('qrcode')
ℹ Loading metadata database
✔ Loading metadata database ... done
 
ℹ No downloads are needed
✔ 1 pkg + 1 dep: kept 2 [3.5s]
Code
library(qrcode)
code=qr_code("https://rfor.us/posit2024slides") 

Save the QR code as a SVG file

Code
generate_svg(code, filename = "qr.svg")
Code
plot(code)

Python

Code
!pip install qrcode scikit-image
Code
import qrcode
img = qrcode.make("https://rfor.us/posit2024slides")
type(img)  # qrcode.image.pil.PilImage
<class 'qrcode.image.pil.PilImage'>

save the QR code as a PNG file

Code
img.save("some_file.png")
Code
from skimage import io
img = io.imread("some_file.png")
io.imshow(img)