CRAN status Project Status: Active – The project has reached a stable, usable state and is being actively developed. Lifecycle: stable GitHub Codecov test coverage GitHub code size in bytes GitHub repo size DOI

QRcode Generator for R A hexagon with the word qrcode and a qrcode linking to the DOI

A QR code is a two-dimensional barcode developed by the Denso Wave company.

The current implementation handles three modes: numeric, alphanumeric and byte. Kanji is currently not supported. Please contact the maintainer if you need it.

Main functions

The main qr_code() function returns an object of the qr_code class. This is a logical matrix with specific methods for printing and plotting. The print version uses UTF-8 drawing symbols and the result depend on the font used. For a better quality QR code it best to use plot() or generate_svg().

library(qrcode)
code <- qr_code("QR CODE")
print(code)
##               
##  ▗▄▄▄  ▗▗▄▄▄  
##  ▐▗▄▐ ▐▟▐▗▄▐  
##  ▐▐█▐▐▞▐▐▐█▐  
##  ▐▄▄▟▗▚▚▐▄▄▟  
##  ▗▖ ▄▖ ▖ ▗▖   
##  ▝▄▜▄▌▘▜▚▛▚█  
##  ▐▜█▚▀▐██▙▙▞  
##  ▗▄▄▄▐▄▞▖▗▟▄  
##  ▐▗▄▐▝▖▖▞▗▟▘  
##  ▐▐█▐ ▞█▛▄▐▄  
##  ▐▄▄▟▐▘▜▀▐▜▝  
##               
##               
## 
## use plot() for a better quality image
plot(code)

A QR code displaying the value 'QR CODE'

generate_svg(code, filename = "man/figures/qr.svg")
A QR code displaying the value ‘QR CODE’

Installation

The qrcode package is available from CRAN, R universe and GitHub.

# install from CRAN
install.packages("qrcode")
# install from R universe
install.packages("qrcode", repos = "https://thierryo.r-universe.dev")
# install from GitHub use the remotes package
remotes::install_github("ThierryO/qrcode")

Legacy code

The legacy function qrcode_gen() has several known bugs. Do check any QR code you create with that function extra careful. Some of them will not work.

Because of these bugs, we re-implemented the code from scratch in version 0.1.4. We created new functions and left the old version in place. Please note that we deprecated the legacy functions. We plan to keep the deprecated functions around until at least June 2022. Update your code before that date.