Track D: Survey and tabular data

Track: Survey and tabular data

Introduction to agentic AI

About this lecture

Every course ends with an evaluation, and many research projects run a questionnaire. The export is messy, and the free-text answers are the most useful part and the slowest to read. An agent can turn the export into a tidy table, plots and a short report in an afternoon. The risks are quiet ones: a reversed item read the wrong way, a group of three students made recognisable, a quote that nobody wrote.

  • Tidy first, with a codebook. One row per respondent, every decision written down.
  • Show the whole distribution of a Likert item, not only its mean: diverging stacked bars.
  • Compare groups plainly, with the number of people behind every percentage, and few planned comparisons.
  • Never report groups smaller than five, and check combinations too.
  • Read student comments yourself. An agent may miss or invent things, and comments can hold sensitive data.

This is a track: a hands-on unit on one kind of data, using the skills from Parts 1 to 4. It builds on Privacy, ethics and safety (synthetic stand-ins), Reproducible figures and A course or project page (Quarto).

The export is messier, and more sensitive, than it looks*

* Evaluation data is often personal and can be sensitive. Before an agent sees it, read Privacy, ethics and safety and the next slides on identification and the safe route.

One script takes the export all the way to the report

“Anonymous” survey answers can still identify a person

The safe route: build on a synthetic stand-in, run on the real file yourself

Course evaluations come with their own rules

Question Short answer (check your own university’s rules)
Are evaluations required? In Sweden, yes: the Higher Education Ordinance (1:14) requires universities to offer them, compile the results and keep them available to students.
Personal data? Yes, if anyone can be identified: through free text, small groups or combinations, even with an “anonymous” survey.
Who may see the raw answers? Usually the course coordinator and a few named people. Not the whole programme board, not a cloud service without approval.
How long are they kept? Your university’s records and archiving rules decide. Do not keep private copies in your Downloads folder.
Public documents? At Swedish public universities, submitted answers may be official documents. Ask your registrar.
Can I use them in research? Not automatically: that is a new purpose, which may need ethics review and information to students.

Today: a synthetic course evaluation with known answers

  • course-evaluation-export.xlsx: an invented course, Cell Biology, spring 2026. 164 students registered.
  • 122 rows: 105 online answers, 15 paper forms typed in by hand, 1 test response, 1 double submission.
  • 12 Likert items (Strongly disagree … Strongly agree). Items 5 and 9 are negatively worded. Item 3 has “Not applicable”.
  • Programme, study mode (campus or distance), age group and gender.
  • Two free-text questions, a few answers in Swedish.
  • Built in on purpose: blanks, a student who stopped halfway, groups of 2, 3 and 4 people, staff names and one identifying comment in the free text.

Because we made the data, we know the right answers: 120 respondents, the counts for every item, two real group differences, and the theme of every comment.

Tidy data: one row per respondent, one column per question

Every kind of mess needs a decision you can see

Mess in the export A decision someone has to make
a test row from before the survey opened remove; say why
two identical rows a minute apart probably one person twice; remove one, and list it
paper forms with numbers 1-5 check that 1 means “Strongly disagree” on the paper form too
“Biomed”, “BMA”, “Bioteknik”, “Läkarprogrammet” map to the programme names; list the mapping
“Not applicable” on item 3 not a scale value: count it separately
blank cells; one student stopped after item 6 missing, not zero; keep the answers they gave
one student “Strongly agree” to all 12 items flag it; decide whether to keep; report both ways if it matters

As in First delegations: ask for a numbered decisions list, and read it.

The tidy step in one prompt

course-evaluation-export.xlsx is a course evaluation export with paper
forms added at the bottom. Do not change it. Write a script that makes:

- survey_tidy.csv: one row per respondent, short column names
  (q01_outcomes ... q12_overall, programme, mode, age_group, gender,
  source = online/paper, plus the two free-text columns); Likert answers
  coded 1-5 as worded; blanks as NA; "Not applicable" as its own code
- codebook.csv: column, full question text, values, reversed (yes/no)
- decisions.md: a numbered list of every row removed and every value
  recoded, with the reason

Items 5 and 9 are negatively worded. Do not reverse them in
survey_tidy.csv; mark them in the codebook. If anything is unclear,
ask me rather than guess. Tell me how many respondents remain.

A codebook keeps the full question next to the short name

Negatively worded items point the other way

A forgotten reversal shows up as an item that disagrees with all the others

Cronbach’s alpha for the 12 items: 0.85 with items 5 and 9 reversed, 0.67 without.

Four kinds of missing answers mean four different things

A mean hides the shape of the answers

  • Report for each item: n, % agree (4-5), % disagree (1-2), and the median.
  • A mean of a Likert item is common and can be useful, but never on its own.

Diverging stacked bars show every item at a glance

A good Likert plot follows a few fixed rules

  • Same colours, same order for every item: disagree in one colour family, agree in the other, neutral in grey.
  • Neutral centred on the zero line, so the eye compares left and right.
  • n on every bar. Item 10 had 9 blanks; the reader should see that.
  • Reversed items marked (R), or shown in a separate group.
  • Full question text available: in the report’s table or a footnote, from the codebook.
  • Colour-blind safe and readable in black and white; no 3D, no pie charts.
  • Same scale (0-100 %) for all items and all groups.

Ask the agent for these rules once, in the prompt or in your project’s instructions file, so every plot follows them.

Comparing groups: put the same bars side by side, with n

A test answers one question: could this be chance?

Item Campus: % agree (n) Distance: % agree (n) Could it be chance?
3 Recordings helped 44 % (73) 86 % (35) very unlikely (p < 0.001)
4 Labs helped 71 % (83) 31 % (36) very unlikely (p < 0.001)
12 Overall satisfied 54 % (81) 64 % (36) quite possible (p = 0.14)
  • With 36 people, a percentage is uncertain by about ±16 points. A 10-point difference between small groups is usually noise.
  • For ordered answers, ask for a rank test (Mann-Whitney) or a comparison of % agree with a confidence interval. Ask the agent to explain its choice in two sentences.
  • Report the size of the difference in percentage points first; the p-value second.

Many comparisons produce some “significant” results by chance

Never report a group smaller than five

Combining groups splits them until one person is left

Think twice before an LLM summarises student comments

  • It can miss things: the one serious comment about harassment, health or safety gets lost in a theme count.
  • It can make mistakes: wrong themes, merged opinions, invented or “improved” quotes.
  • Comments can hold sensitive data: names of staff and students, health, personal circumstances. Sending them to a cloud service may not be allowed (Privacy, ethics and safety, Open-weights models and data privacy).
  • Our recommendation: read every comment yourself. If your institution allows an agent at all, use it only to organise comments you have read, never as the only reader.

If you use an agent on free text: themes in minutes, checked by you

  • Ask for a theme list with a count, and for every comment’s respondent id and theme in a table you can check.
  • Swedish and English comments in one list; the agent can translate, but quotes stay in the original language.

A summary can be checked; an invented quote is fabricated evidence

Check every quote against the data, word for word

  • A script compares each quote with the export: exact match, with respondent id. Not the agent’s memory.
  • Then you open the export and read three quotes in context.

Theme counts are judgement: check a sample yourself

  • Two careful people code the same comments differently at the edges. So does an agent, between runs.
  • Code 15 comments yourself, before you look at the agent’s themes. Compare: where do you disagree, and why?
  • Ask a second agent (or a fresh session) to code the same comments from the same theme list. Compare the counts.
  • Report themes as “about 15 comments”, not “26.8 %”. The precision is not there.
  • Keep the table of comment, respondent id and theme with the analysis, not in the report.
Here are the themes from the earlier session: [list]. Assign each comment
in survey_tidy.csv to one theme or "other". Output a table with
respondent id, theme and the comment. Do not create new themes.

Some comments must not be quoted at all

Comment contains Example from the synthetic data What to do
a staff member’s name, positive “Erik in the lab was always willing to explain again.” report the theme (“teaching assistants were helpful”), not the name
a named complaint about staff “Lecturer Anna Berg was dismissive…” not in the board report; follow your university’s routine for complaints
health or disability “As the only wheelchair user in the group…” report the issue (lab benches in B214 too high), never the quote
something that identifies the writer “the only”, “my supervisor”, a rare situation paraphrase the issue without the identifying detail
insults or personal data about others names of fellow students leave out; tell the coordinator if action is needed

Ask the agent to flag such comments for you to decide; do not let it decide alone.

The report for the board is short, plain and generated from the script

The report prompt names the audience, the content and the rules

Write report.qmd, a Quarto report (HTML and PDF) for the programme
board: at most two pages. Use survey_tidy.csv and codebook.csv.

Content: response rate (164 registered); three key messages in plain
language; one diverging stacked bar chart of all 12 items (as worded,
reversed items marked R, n on every bar); campus vs distance for
items 3, 4 and 12 only, with n and % agree; free-text themes with
approximate counts and at most three short quotes; proposed actions
(leave a placeholder for me); a method section (tools, decisions
from decisions.md, use of an AI agent, how results were checked).

Rules: no group or table cell below 5 people; no names of students or
staff; no quote that identifies anyone; every quote copied exactly
from the data. Then run check_quotes.py on the report and show me
the table.

Where this goes wrong

  • Reversed items averaged as worded. The course score is wrong; alpha drops. Check the item-agreement plot.
  • Blanks as 0 or 3. Every mean shifts. Count NA per item and compare with the export.
  • Test rows and double submissions kept. Count respondents: you know the expected number.
  • Means only. A split class looks neutral. Show the distribution.
  • Every comparison tested. Some “differences” are luck. Plan the comparisons.
  • Small groups and combinations. Four exchange students are four people. k ≥ 5, everywhere.
  • Invented or altered quotes. Check by script, word for word, then read three in context.
  • Real evaluation data in the cloud without approval. Build on a synthetic stand-in.

What the agent does and does not do here

The agent does well You do
read the messy export and write the tidy script decide which rows to remove and how to code paper forms
make the codebook, decisions list and plots check the codebook against the questionnaire
run tests and explain them in plain words choose the few comparisons that matter
suggest themes and code comments fast code a sample yourself; decide on sensitive comments
check quotes and cell sizes by script read quotes in context; take responsibility for the report
draft the Quarto report write the proposed actions; present it to the board

Summary

Concept Key fact
Tidy data one row per respondent, one column per question; raw export untouched
Codebook and decisions full question, coding, reversed items; every removal listed
Reverse coding 6 − answer, for scores only; a negative item-agreement bar means “check reversal”
Missing blank, not applicable, stopped, no reply: four meanings; never 0 or 3
Likert description n, % agree, % disagree, median; diverging stacked bars

Summary (continued)

Concept Key fact
Group comparison side-by-side bars with n; plan few comparisons; size first, p-value second
Small cells never a group or cell below 5; check combinations (k-anonymity)
Free text real comments: read them yourself; an agent may miss, err, and see sensitive data
Quotes checked by script, word for word; no names, nothing identifying
Privacy real evaluations: synthetic stand-in for the agent, run the script yourself

Next (Parallel workers: Claude and Codex): two agents at once, the same task given to both, and one agent checking the other’s work. Or continue with another track.