How to use qrlabelr

Ebenezer Ogoe and Alexander Kena

Table of contents


qrlabelr is an R package that provides customizable functions and an intuitive ‘shiny’ app for generating print-ready machine and human-readable labels affixed with QR codes. The app is designed to be user-friendly, fast and efficient, allowing researchers to create accurate and highly informative plot labels without the need for licensed commercial software.

It generates field plot labels that are compatible with the widely used digital data collection mobile app, Field Book. Our software builds on the foundation of an existing open-source program to offer more flexibility in plot label creation steps; guarantees true string fidelity after QR encoding; and provides faster label generation to users.

This vignette will guide you through the process of installing the package, and how to use its customizable functions, and the ‘shiny’ app.


To install qrlabelr, you will first need to have R and the ‘RStudio’ IDE installed on your computer. Once you have these tools installed, you can open ‘RStudio’ and enter the following command in the console to install the package from CRAN:


The development version of qrlabelr can be installed from GitHub as follows: install.packages("devtools")

Now, install the qrlabelr package by running the following commands:


Alternatively, you can install the package together with its vignettes as follows:

devtools::install_github("awkena/qrlabelr", build_vignettes = TRUE)

One must have the knitr package installed before vignettes can be built during package installation.

To view vignettes for the package in ‘RStudio’, run the following code in the R console:


Similarly, the vignette can be viewed in your browser by running the following code in your R console:


The method described above will download and install the qrlabelr package on your computer. Once the installation is complete, you can load the package by entering the following command in the console:


Users who have R and RStudio already installed must ensure they are up to date before installing qrlabelr. All installed packages must also be updated before installing qrlabelr from GitHub


Generating field books

To use qrlabelr, one must first generate a field book or data input that shows individual experimental plot or label attributes. A field or study book is required as an input data input in qrlabelr for plot labels. For seed packet labels, a data input containing the attributes of the seed samples must be provided.

Typically, layout information for field plots are obtained based on the experimental design and treatment randomization. For field plot labels, it is strongly recommended to have the grid coordinates of plots (row and column numbers of plots) included in the field book.

There are free open-source software such as FielDHub, which users can use to easily generate an input field book for plot label design in qrlabelr. Other user-preferred software such as ‘BMS’ or ‘breedbase’ can equally be used to generate an input field book if desired. The qrlabelr package is ‘BrAPI- compliant’.

In R, users can use available functions in the ‘QBMS’ package to query ‘BrAPI’-supported databases for input field books. A user-friendly UI component for accessing data from ‘BrAPI’-supported databases is available in the ‘shiny’ app.

For BrAPI compliance, users must install the ‘async’ package in addition to the ‘QBMS’ package as follows:


Input data must be imported as a data frame into qrlabelr for use. We recommend that users save input data as csv or as xls or xlsx files for easy import to qrlabelr.

Plot label design options

The qrlabelr package offers two user-centered options for creating plot labels affixed with QR codes.

The first option involves the use of customizable functions to create rectangular field plot labels or any rectangular general-purpose labels embossed with QR codes. This option is for users who find working in R comfortable.

The package also provides a helper function to access a user-friendly ‘shiny’ app (‘EasyQrlabelr’) for non-R users who may find working in R not so comfortable. This option allows users to run the ‘shiny’ app using their computer as host without the need for internet.

Both the customizable functions and ‘shiny’ app were created to deliver the exact same features, so it all boils down to a user’s preference.

You can choose to create labels using the ‘shiny’ app, or with the use of customizable functions in R. It boils down to a user’s preference, as both the functions and ‘shiny’ app were created to deliver the exact same features. We were only motivated by the need to serve both groups – those comfortable with working with codes, and those who prefer to work with a GUI-based application.

Label content

The qrlabelr package designs machine and human-readable plot labels. The specific information that is displayed on labels depends on whether one is designing field plot labels for field experiments or any general purpose label. The general-purpose label option comes with two text orientation formats on the label: landscape (Figure 1) and portrait (Figure 2) formats.

Figure 1 and 2 show delineated text positions available to users that can be filled with human-readable text items and machine-readable QR code.

Fig. 1. Plot label design and content in qrlabelr for a landscape text orientation label format. A. There are nine (9) delineated text positions and 1 QR code position for any rectangular label (A). For a field plot label, the nine delineated text positions are mapped to specific human-readable texts by default as shown in B.
Fig. 2. Plot label design and content in qrlabelr for a portrait text orientation label format. A. There are ten (10) delineated text positions and 1 QR code position for any rectangular label with portrait text orientation. B. An example of a general-purpose label with a portrait text orientation.

For a field plot label option, a landscape text orientation is used. The text nine (9) text positions are mapped by default to the following human-readable text items as shown in Figure 1.

  1. Top-left row 1 text position is mapped to Plot ID 
  2. Top-left row 2 text position is mapped to Row ID 
  3. Top-right row 1 text position is mapped to Rep ID 
  4. Top-right row 2 text position is mapped to Column ID 
  5. Center-right row 1 text position is mapped to intra-block ID number if the field layout is based on an incomplete block design 
  6. Center-right row 2 text position is mapped to seed source for entries (optional) 
  7. Center-right row 3 text position is mapped to name of researcher (optional) 
  8. Bottom-left row 1 text position is mapped to Location of experiment or trial 
  9. Bottom-left row 2 text position is mapped to Entry name 

To change any of these default human-readable text items to specific user-preferred texts, use the gp_label() customizable function in R or the General-purpose landscape text label method in the ‘shiny’ app..

QR code generation

Affixing QR codes on the plot labels makes them machine-readable for easy plot identification and tracking. The text for generating QR codes must be unique for each plot.

The qrlabelr package provides three methods for producing unique IDs for each plot. These methods are reproducible unique IDs (RUID), universal unique IDs (UUID), and custom unique IDs (custom). The RUID method is, however, only available when the user chooses the field_label() function in R or the Field plot label option in the ‘shiny’ app.

RUIDs are informative and reproducible, hence, can be regenerated when provided with the same input field book. For field experiments or trials, we strongly recommend the use of RUIDs. An RUID is generated by concatenating LOCATION and year of experiment, trial name, PLOT, ROW and COLUMN ids for each experimental plot Eg. KUMASI2023_PYT_101_1_1.

The UUID method produces random time-based unique IDs that are not reproducible and informative, but are highly unique due to their pseudo-random nature.

if the input field book contains a column that represents unique IDs suitable for QR code generation, the user can choose the 'custom' method.

Users can set the desired error correction level (ecl) for generating QR codes. The ecl indicates how much of the QR code is used up for error correction. There are four levels, with 0 (7%) being the lowest level and 3 (30%) being the highest value possible. For field experiments, we strongly recommend that the error correction level be set to 3, which is the default setting.

Creating field plot labels in R

To create field plot labels in R, use the field_label() function. This function creates rectangular field plot labels based on a template, where the page setting and label dimension parameters can be defined by the user using specific arguments.

For instance, to create field plot labels based on the Avery 94241 template, the field_label() function is used as shown in the code snippet below:


field_label(dat = qrlabelr::square_lattice,
            wdt = 5, 
            hgt = 2,
            page_wdt = 8.5, 
            page_hgt = 11,
            top_mar = 0.75, 
            bot_mar = 0.75, 
            left_mar = 1.75, 
            right_mar = 1.75, 
            numrow = 4L, 
            numcol = 1L, 
            rect = TRUE,
            print_across = TRUE,
            filename = paste0(tempfile()), 
            font_sz = 20, 
            Trial = 'PYT', 
            Year = 2023, 
            family = 'sans', 
            rounded = TRUE, 
            IBlock = TRUE,
            get_unique_id = "ruid", 
            rname = "AW Kena", 
            seed_source = TRUE, 
            seed_source_id = "SEED_SOURCE" 

The above example creates field plot labels using a sample field book named square_lattice generated with the FielDHub package. The square_lattice sample field book is available in the qrlabelr package, and it was generated based on a Square Lattice Design layout at two locations.

It follows from the above example that to create any custom rectangular label based on a template, users must specify page setting and label dimension parameters using the following arguments:

It follows from the above examples that to create any custom rectangular label based on a template, users must specify page setting and label dimension parameters using the following arguments:

The example above creates labels with QR codes generated using the reproducible unique IDs method (get_unique_id = "ruid"); researcher’s name = "AW Kena"; intra-blocks (IBlock = TRUE); and a font family of family ='sans'.

The arguments Trial = 'PYT' and Year = 2023 are required if the method for generating unique IDs for QR codes is set to get_unique_id = "ruid". Users can set the font size for the label using the font_sz argument. Rectangular labels with rounded corners are generated with the argument rounded = TRUE, else set it to rounded = FALSE.

Users have the option to draw rectangles around labels or make labels without rectangular borders via the rect = TRUE argument. Set this argument to TRUE for rectangles or FALSE for no rectangles.

The print_across argument provides options for users to fill pages with labels by row (left to right) or by column (top to down). Set to TRUE to fill pages by row or FALSE to fill pages by column.

The following arguments must also be specified if the input field book was not generated with the FielDHub package:

The arguments seed_source = TRUE and seed_source_id = "SEED_SOURCE" are optional and should be used only when the user intends to show seed source on the field label.

The function creates a pdf file with a name prefix of 'PlotLabel' that is saved to the user’s working directory. The function also saves an updated field book to the user’s working directory which can be exported to the Field Book mobile app for digital data collection.

Creating general-purpose labels in R

The gp_label() and the gp_label_portrait()functions allow for specific user-defined or preferred human-readable text items to be displayed on a label. These texts can be used to fill out the delineated text positions on the label (Figure 1 and 2). These functions give a lot of control to the user with respect to what human-readable text items, their position, and orientation on the label.

To create any general-purpose label with a landscape text orientation, invoke the gp_label() function as has been done in the code snippet below:

gp_label(dat = qrlabelr::square_lattice,
         get_unique_id = "uuid",
         font_sz = 10,
         family = "sans",
         rect = TRUE,
         print_across = FALSE,
         filename = paste0(tempfile()),
         top_left_txt1 = 'Plot:',
         top_left_txt2 = 'Row:', 
         top_right_txt1 = 'Rep:',
         top_right_txt2 = 'Col:',
         center_right_txt1 = 'iBlock:',
         center_right_txt2 = 'Seed:',
         center_right_txt3 = 'Adepa',
         bottom_left_txt1 = 'Loc:',
         top_left_id1 = 'PLOT',
         top_left_id2 = 'ROW',
         top_right_id1 = 'REP',
         top_right_id2 = 'COLUMN',
         center_right_id1 = 'IBLOCK',
         center_right_id2 = 'SEED_SOURCE',
         bottom_left_id1 = 'LOCATION',
         bottom_left_id2 = 'TREATMENT'

The above arguments are passed to the create_label() function to generate the desired labels based on the defined page setting and label dimension parameters.

The gp_label_portrait() function is, however, a standalone function that places human-readable text items on the label in a portrait orientation as shown in Figure 2. The code snippet below demonstrates how to use the gp_label_portrait() function in R.

dat <- qrlabelr::square_lattice

dat$ids <- paste0(dat$LOCATION,'2023', '_PYT', '_', dat$PLOT, '_', dat$ROW, '_', dat$COLUMN)
  wdt = 2,
  hgt = 1, 
  page_wdt = 8.5, 
  page_hgt = 11,
  top_mar = 0.625,
  bot_mar = 0.625,
  left_mar = 0.625,
  right_mar = 0.625,
  numrow = 8L,
  numcol = 3L,
  filename = paste0(tempfile()),,
  font_sz = 10,
  family = 'sans', 
  rounded = TRUE,
  rect = TRUE,
  print_across = FALSE,
  bot_txt1 = 'Rubi', 
  cent_txt2 = 'Rep:',  
  cent_txt3 = 'R:', 
  cent_txt4 = 'r:', 
  top_txt1 = 'P:', 
  top_txt2 = 'B:',
  bot_txt2_id = 'ids',
  bot_txt3_id = 'LOCATION',
  cent_txt1_id = 'TREATMENT', 
  cent_txt2_id = 'REP', 
  cent_txt3_id = 'COLUMN', 
  cent_txt4_id = 'ROW', 
  top_txt1_id = 'PLOT',
  top_txt2_id = 'IBLOCK',
  top_txt3_id = 'SEED_SOURCE',
  unique_id = 'ids',
  ec_level = 1

To view details of the field_label(), the gp_label(), and gp_label_portrait() functions in ‘RStudio’, run the following codes in the R console:


Note that the default label template for the above functions is Avery 94220 template..

Creating labels with ‘shiny’ app: EasyQrlabelr

To create your first plot label using the ‘shiny’ app, you will need to open the ‘EasyQrlabelr’ ‘shiny’ app. You can do this by entering the following command in the console:


This will open a new window in your default web browser that displays the ‘EasyQrlabelr’ ‘shiny’ app. The user is then greeted with a Welcome page that provides an overview of the web app, some quick instructions to get started, sample labels, among others. In the header of the web app is a convenient Help button which can be accessed anytime for a quick overview of the purpose of each tab in generating a label.

Figure 3 shows the main pages or tabs available in the ‘shiny’ app and their corresponding features.