Learn R Programming

quallmer

The quallmer package is an easy-to-use toolbox to quickly apply AI-assisted qualitative coding to large amounts of texts, images, pdfs, tabular data and other structured data.

Using qlm_code(), users can apply codebook-based qualitative coding powered by large language models (LLMs) to generate structured, interpretable outputs. The package includes built-in codebooks for common applications and allows researchers to create custom codebooks tailored to their specific research questions using qlm_codebook(). To ensure quality and reliability of AI-generated coding, quallmer provides qlm_compare() for evaluating inter-rater reliability and qlm_validate() for assessing accuracy against gold standards. With qlm_replicate(), researchers can systematically compare results across different models and settings to assess sensitivity and reproducibility. The qlm_trail() function creates complete audit trails following Lincoln and Guba’s (1985) concept for establishing trustworthiness in qualitative research.

The quallmer package makes AI-assisted qualitative coding accessible without requiring deep expertise in R, programming or machine learning.

The quallmer workflow

1. Define codebook and prepare data

qlm_codebook()

  • Creates custom codebooks tailored to specific research questions and data types.
  • Uses instructions and type specifications from ellmer to define coding instructions and output structure.
  • Example codebook objects (e.g., data_codebook_sentiment) demonstrate how to use built-in codebooks for common qualitative coding tasks.
  • Extensible framework allows researchers to define domain-specific coding schemes.

2. Code data

qlm_code()

  • Applies LLM-based coding to qualitative data using a qlm_codebook.
  • Works with any LLM supported by ellmer.
  • Returns a qlm_coded object containing the coded results and metadata for reproducibility.

qlm_segment() (optional)

  • Segments texts into thematic or conceptual units using an LLM.
  • Useful for aspect-based analysis, quasi-sentence segmentation, or splitting texts by topic.
  • Returns a corpus of segmented units that can be coded with qlm_code() for more granular analysis (in the same pass or as a separate step).

3. Replicate with different settings

qlm_replicate()

  • Re-executes coding with optional overrides (different models, codebooks, or parameters).
  • Tracks provenance chain for comparing results across different configurations.
  • Enables systematic assessment of coding reliability and sensitivity to model choices.

4. Compare and validate results

qlm_compare()

  • Compares multiple qlm_coded objects to assess inter-rater reliability.
  • Computes agreement metrics including Krippendorff’s alpha, Cohen’s kappa, and Fleiss’ kappa. When comparing documents that have been segmented, automatically computes all four variants of Krippendorff’s alpha for unitizing (2019, section 12.6) – the only R package to do so.
  • Useful for evaluating consistency across different coders, models, or coding runs.

qlm_validate()

  • Validates LLM-coded output against gold standard human coding.
  • Computes classification metrics: accuracy, precision, recall, F1-score, and Cohen’s kappa.
  • Supports multiple averaging methods (macro, micro, weighted) and per-class breakdowns.

5. Document audit trail

qlm_trail()

  • Creates complete audit trails following Lincoln and Guba’s (1985) concept for establishing trustworthiness.
  • Captures the full decision history: models, parameters, timestamps, and parent-child relationships.
  • Stores all coded results for confirmability and dependability.
  • Reconstructs branching workflows when multiple coded objects are compared or validated.
  • Generates replication materials: environment setup, API configuration, and executable R code.
  • Use qlm_trail(..., path = "filename") to save RDS archive and Quarto report.

Interactive quallmer app

For an interactive Shiny application to perform manual coding, review AI-generated annotations, and compute agreement metrics, see the companion package quallmer.app.

Supported LLMs

The package supports all LLMs currently available with the ellmer package. For authentication and usage of each of these LLMs, please refer to the respective ellmer documentation and see our tutorial for setting up an OpenAI API key or getting started with an open-source Ollama model.

Installation

You can install the development version of quallmer from https://github.com/quallmer/quallmer with:

# install.packages("pak")
pak::pak("quallmer/quallmer")

Example use and tutorials

To learn more about how to use the package, please refer to our step-by-step tutorials.

Acknowledgments

Development of this package was assisted by Claude Code, an AI coding assistant by Anthropic, for code refactoring, documentation updates, and package restructuring.

References

Krippendorff, K. (2019). Content Analysis: An Introduction to Its Methodology (4th ed.). Sage. doi:10.4135/9781071878781

Copy Link

Version

Install

install.packages('quallmer')

Monthly Downloads

365

Version

0.4.0

License

GPL (>= 3)

Maintainer

Seraphine F. Maerz

Last Published

May 6th, 2026

Functions in quallmer (0.4.0)

qlm_codebook

Define a qualitative codebook
print.qlm_codebook

Print a qlm_codebook object
print.trail_setting

Print a trail_setting object
qlm_trail

Create an audit trail from quallmer objects
trail_record

Trail record: reproducible quallmer annotation (deprecated)
trail_icr

Compute inter-rater reliability across Trail settings (deprecated)
qlm_segment

Segment texts using an LLM
qlm_validate

Validate coded results against a gold standard
qlm_code

Code qualitative data with an LLM
qlm_compare

Compare coded results for inter-rater reliability
trail_matrix

Convert Trail records to coder-style wide data (deprecated)
validate

Validate coding: inter-rater reliability or gold-standard comparison
trail_settings

Trail settings specification (deprecated)
qlm_replicate

Replicate a coding task
qlm_meta

Get or set quallmer object metadata
qlm_humancoded

Convert human-coded data to qlm_coded format (deprecated)
task

Define an annotation task (deprecated)
trail_compare

trail_compare: run a task across multiple settings and compute reliability (deprecated)
print.trail_compare

Print a trail_compare object
print.trail_record

Print a trail_record object
[.qlm_corpus

Subset method for qlm_corpus objects
quallmer-package

quallmer: Qualitative Analysis with Large Language Models
as_qlm_corpus

Coerce to qlm_corpus
accessors

Accessor functions for quallmer objects
as_qlm_coded

Convert coded data to qlm_coded format
print.qlm_coded

Print a qlm_coded object
data_corpus_manifsentsUK2010sample

Sample of UK manifesto sentences 2010 crowd-annotated for immigration
print.qlm_trail

Print a quallmer trail
data_corpus_MPexamples

Manifesto Project example manifestos and gold-standard segmentation
annotate

Apply an annotation task to input data (deprecated)
codebook

Extract codebook from quallmer objects
as_qlm_codebook

Convert objects to qlm_codebook
data_corpus_ms2020sample

Sample corpus of political speeches from Maerz & Schneider (2020)
inputs

Extract input data from qlm_coded objects
print.qlm_corpus

Print method for qlm_corpus objects
print.qlm_comparison

Print a qlm_comparison object
data_corpus_LMRDsample

Sample from Large Movie Review Dataset (Maas et al. 2011)
data_codebook_immigration

Immigration policy codebook based on Benoit et al. (2016)
print.qlm_validation

Print a qlm_validation object
print.task

Print a task object
data_codebook_sentiment

Sentiment analysis codebook for movie reviews