Learn R Programming

qrlabelr (version 0.2.0)

make_qrcode: Make QR codes

Description

A helper function for QR code generation using the 'qrencoder' library for faster QR code generation. It converts the generated QR code into a raster grob image that can be plotted using the `grid.draw()` function in the 'grid' package.

Usage

make_qrcode(my_id, ec_level = 3)

Value

A QR code as a raster grob image object that can be plotted with the `grid.draw()` function in the 'grid' package.

Arguments

my_id

Unique ID string to be encoded to QR code.

ec_level

The error correction level (`0` - `3`, lowest to highest).

Examples

Run this code
if (FALSE) { # rlang::is_installed(c("raster", "qrencoder", "assertthat", "grid"))
library(qrlabelr)
qr <- make_qrcode("KUMASI2023_PYT_101_1_1", ec_level = 1)

# Plot QR code using the grid package
grid::pushViewport(grid::viewport(x = grid::unit(0.5, "npc"),
                                  y = grid::unit(0.5, "npc"),
                                  width = grid::unit(1, "in"),
                                  height = grid::unit(1, "in")))
grid::grid.draw(qr)
# clean up any open graphical device
# grDevices::graphics.off()
}

Run the code above in your browser using DataLab