llm_persona_split: Split one persona into labeled demographics and labeled...

View source: R/personas.R

llm_persona_splitR Documentation

Split one persona into labeled demographics and labeled answers

Description

Extracts row i of a persona frame into two named character vectors: the demographic fields and the survey/attitude answers. Names are the question wording when the frame carries a dictionary, otherwise the column handles. Missing values are dropped, and any score/index column (e.g. ideology_score) is treated as metadata, not an answer. This is the shared field-extraction step; how the result becomes prompt text is up to the caller.

Usage

llm_persona_split(x, i, drop = "ideology_score")

Arguments

x

A persona data frame (see anes_2024_personas).

i

Integer row index.

drop

Character vector of column names to exclude from both parts (defaults to "ideology_score").

Value

A list with two named character vectors, demographics and responses.

See Also

llm_persona_demographic_fields(), anes_2024_personas.

Examples

data(anes_2024_personas, package = "LLMR")
parts <- llm_persona_split(anes_2024_personas, 1)
names(parts$demographics)[1:3]

LLMR documentation built on July 11, 2026, 1:06 a.m.