Skip to content

giobuzala/forage

Repository files navigation

An interactive Shiny app for AI-assisted coding of open-ended survey responses.

Overview

forage is an interactive Shiny application for coding open-ended survey responses into structured qualitative themes using OpenAI’s language models.

It is designed for survey researchers and analysts who want a faster, more consistent, and more transparent way to generate code frames and apply them to large volumes of verbatim responses without losing human control over the process.

The workflow is explicitly human-in-the-loop: generated theme lists can be reviewed, edited, or replaced before coding begins.

Access

forage is deployed on shinyapps.io. Use it at https://giobuzala.shinyapps.io/forage/. Best experienced on desktop or tablet.

How it works

  1. Upload a survey Excel file (.xlsx or .xls) that contains:

    • a respondent ID column
    • an open-ended response column
  2. Theme generation creates a theme list:

    • Code - a unique numeric code for each theme (e.g., 1, 2, 3)
    • Bin - short descriptive label for the theme (e.g., "Trust", "Price", "Service")
    • Description - a brief explanation of what the theme represents
  3. Coding responses assigns all applicable codes from the theme list to each response. The output is an Excel file with two sheets:

    • Coded Responses
    • Theme List

This structure keeps the coding transparent and auditable, making it easy to review results, share with collaborators, or feed into downstream analysis workflows.

Methodology

This tool uses AI to assist with generating themes and coding open-ended survey responses. The resulting themes and codes are based on probabilistic interpretations of text and may differ from how a human researcher would code the same responses.

As a best practice, generated themes should be reviewed before coding, with results validated against research objectives and human judgment applied where nuance or ambiguity exists.

This tool is designed to accelerate qualitative analysis, not to replace expert review or methodological oversight.

Data security

AI processing is performed only to generate requested outputs. OpenAI does not train its models on data submitted through the API. Data is handled in accordance with OpenAI's API data-usage policies and is not used for advertising, profiling, or model improvement.

Users are responsible for ensuring that their use of AI tools complies with applicable data-handling, privacy, and confidentiality requirements.

Learn more at Business data and Your data.

Files

  • app.R Shiny UI with two steps: generate themes, then code responses.
  • Functions/theme_gpt.R Generates a theme list from open-ended responses.
  • Functions/code_gpt.R Codes responses using a provided theme list.

Local set up

  1. Install packages:
install.packages(c(
  "dotenv", "dplyr", "httr2", "openxlsx", "purrr", "readxl", "shiny", "shinyjs", "stringr"
))
  1. Set your OpenAI API key using one of the following methods:
Sys.setenv(OPENAI_API_KEY="your_api_key")

Or create a local .Renviron file in the project root:

OPENAI_API_KEY="your_api_key"
  1. Start the app:
shiny::runApp("app.R")

License

This project is released under a custom non-commercial license authored by the project owner.

About

AI-assisted open-ended coding agent

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages