Skip to contents

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.

Examples

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