Using AI in ID 543

AI tools can be useful coding assistants, but they are not authorities. In this course, the goal is to learn R well enough that you can decide whether an AI suggestion is appropriate, run it, check it, and explain it.

Course policy

You may use AI tools such as ChatGPT, Claude, Gemini, Copilot, or similar systems for:

  • explaining error messages
  • asking for examples using functions we have covered in class
  • debugging code you wrote
  • checking whether your logic matches the assignment
  • suggesting code you can run to verify your work
  • improving comments or written explanations after you understand your analysis

You may not use AI tools to:

  • submit code you cannot explain
  • replace your own decisions about how to approach the problem
  • ask for a complete answer to a homework or project and submit it with minimal changes
  • avoid reading the course materials, documentation, or assignment prompt
  • enter confidential, student, patient, unpublished, or non-public research data into a public AI tool

You remain responsible for everything you submit. AI-generated code can be wrong, use functions we have not covered, silently change the goal of the assignment, or produce results that look plausible but are not correct.

What to submit

For every homework and the final project, include an AI appendix at the end of your submission. If you used AI, include:

  • the full AI conversation transcript, copied into the appendix or attached as a separate file
  • a short note describing what you asked AI to help with
  • a short note describing what you accepted, changed, or rejected
  • at least one code chunk that checks whether your answer looks right
  • one sentence explaining the result in your own words

If you did not use AI, that’s totally fine (the course and classwork is achievable without AI and students have successfully completed it without AI in the past). Just include a statement that you did not use AI in the AI appendix.

A good AI prompt

Strong prompts give the model the assignment, the course context, the data context, your attempted code, and the exact thing you want help checking.

I am in an introductory R course using tidyverse.
We have covered these functions: mutate(), case_when(), factor(), count(), summary().

I'm try to:
[describe a specific task]

My data has these variables:
[paste names(nlsy) or glimpse(nlsy) output]

Here is the code I tried:
[paste your code]

Here is the error message or output:
[paste the message/output]

Please help me understand what is wrong without using functions we have not covered.
Please also suggest one or two ways I can verify that the result is correct.

A weaker AI prompt

Do question 4.

This is weak because the model does not know the course tools, the dataset, the wording of the question, or what you already tried. It also encourages you to receive an answer instead of learning how to solve and check the problem.

Checking AI-assisted work

Before submitting AI-assisted code, run checks that match the type of task.

Task Useful checks
Reading data glimpse(), dim(), names(), summary()
Creating a variable summary(), count(), compare old and new variables
Creating categories count(), tabyl(), cross-tab raw values with labels
Selecting columns names(), ncol(), setequal()
Filtering rows nrow() before and after filtering; check the condition in the filtered data
Grouped summaries compare one group by hand; include n = n()
Joins count rows before and after; check unmatched records; inspect duplicated keys
Plots check axis variables, legends, labels, missing values, and whether the plot answers the question

Examples:

# Check a new categorical variable
count(nlsy, age_bir_cat)
count(nlsy, age_bir_cat, age_bir)
# Check whether two filtering approaches return the same number of rows
male_by_number <- filter(nlsy, sex == 1)
male_by_label <- filter(nlsy, sex_cat == "Male")

nrow(male_by_number)
nrow(male_by_label)

A useful workflow

  1. Try the problem yourself first; ask classmates/teaching team.
  2. Ask AI a specific question with course and data context.
  3. Run the suggested code line by line.
  4. Remove or rewrite anything you do not understand.
  5. Check the result with independent code or output.
  6. Explain the final answer in your own words.

University resources