Skip to contents

Survey response classification with LLMs. A domain wrapper around cat.stack that adds survey_question context for open-ended survey response analysis.

cat.survey wraps the Python cat-survey package via reticulate.

Installation

# From R-universe (recommended)
install.packages("cat.survey",
                 repos = c("https://chrissoria.r-universe.dev",
                          "https://cloud.r-project.org"))

# Or from a local clone
devtools::install("path/to/cat.stack")
devtools::install("path/to/cat.survey")

# Install the Python backend (one-time setup)
# pip install cat-survey

Quick Start

Classify survey responses

library(cat.survey)

results <- classify(
  input_data      = df$responses,
  categories      = c("Economic", "Family", "Education", "Other"),
  survey_question = "Why did you move to this city?",
  api_key         = Sys.getenv("OPENAI_API_KEY")
)

Extract categories

result <- extract(
  input_data      = df$responses,
  survey_question = "What do you like about your neighborhood?",
  api_key         = Sys.getenv("OPENAI_API_KEY")
)
print(result$top_categories)

Explore raw categories

raw_cats <- explore(
  input_data      = df$responses,
  survey_question = "Why did you move?",
  api_key         = Sys.getenv("OPENAI_API_KEY"),
  iterations      = 3L
)

Functions

Function Description
classify() Classify survey responses into categories
extract() Discover and extract categories from survey data
explore() Get raw category extractions for saturation analysis

License

MIT