PUBH 523/623: Interactive R Practice

Welcome! This site hosts the weekly practice assignments for PUBH 523/623. Each practice page lets you try out that week’s lessons right in your browser: the R code you write here runs using webR, so you can start before you have everything set up in RStudio.

TipThe short version
  1. Watch the week’s lessons on the course schedule.
  2. Work through that week’s practice page here, and fill in the AI Use Statement near the end.
  3. Click Download my answers as .qmd at the bottom of the page.
  4. Save it in your course folder, open it in RStudio, and render it.
  5. Submit both the .qmd and the .html on Brightspace by Sunday at 11pm.

What the practice assignments are

There is one practice assignment each week, and it covers that week’s lessons. Practice is for learning, not for testing you, so:

  • It’s graded on completion. You get a check if you complete at least 75% of the question parts, whether your answers are right or wrong. Each practice counts equally.
  • It’s due Sunday at 11pm. On-time work gets feedback from me. You can still turn it in any time before the course ends for full credit, just without feedback (unless you email me to ask).
  • Working together is encouraged! Talk it through with classmates, but everyone submits their own work.

See the schedule for due dates and the syllabus for the full grading details.

How to complete a practice page

Pick a practice from the Practice Exercises menu above. Each page starts with a table of that week’s lessons (with links to the videos and slides), then walks through the ideas step by step. You’ll see a few kinds of questions.

Code questions

These have a small R editor you can type straight into. Most start with a ______ blank to replace with your code. Some “fix the error” questions start with broken code instead: run it, read the error, and fix it. Then use the buttons above the editor:

  • Run Code: runs your code and checks it. A green box means you’ve got it. Any other color means it’s not quite right yet, and the message will nudge you toward the fix.
  • Show Hint: reveals a hint. Some questions have more than one, so keep clicking if you’re still stuck.
  • Start Over: resets the editor to the starting code.
  • Format: tidies up the spacing in your code so you can see what nicely formatted R looks like.

Multiple choice and short answer questions

Some answers are words, not code. For these, pick an option and you’ll get the same green or “not quite” feedback right away. For select all that apply questions (and typed answers), make your choices, then click Check my answer. Open the Hint box under the question if you get stuck.

Self-check tasks

Some tasks happen outside the page, like setting up your course folder, making an R Project, or the hands-on steps in RStudio at the end of each practice. Check the box once you’ve done it. These can’t be graded automatically, so they’re just for keeping track.

NoteGetting it wrong is part of it

The practice pages don’t show worked solutions. The feedback messages and hints are there to guide you toward the answer, and a wrong answer still counts toward completion. If you’re stuck after the hints, ask on Slack or come to office hours!

Your work is saved in this browser only

As you work, the code you type, your multiple choice and short answers, and your checkmarks on the My Progress page are saved automatically in your browser. Close the tab, come back tomorrow, and your work will still be there, as long as you use the same browser on the same device and haven’t cleared your browsing data.

That’s not a permanent save. Clearing your cache, using a private/incognito window, or switching browsers or computers will lose it. Your downloaded .qmd is your real copy, so download it when you finish, and again any time you want a backup.

How to turn it in

Every practice page ends with a Download my answers as .qmd button. That file is a real Quarto document with all of your answers, numbered to match the page: code answers go in R chunks, multiple choice and short answers go in as text, and your AI Use Statement goes at the top. It also has sections for the hands-on steps at the end of the page. Practice 1 walks you through these steps in detail the first time.

  1. Fill in the AI Use Statement near the bottom of the page. If you didn’t use AI, just pick “I did not use AI.” (More below.)
  2. Download your answers with the button at the bottom of the page.
  3. File it. Move the file from your Downloads folder into the practice folder inside your course folder, and rename it to lastname_firstinitial_practice_##.qmd (for example, wakim_n_practice_01.qmd). No spaces!
  4. Open it in RStudio and put your name in the author: line at the top. Starting with Practice 2, open your course’s R Project first (double-click PUBH_523_26F.Rproj), then open the file from the Files pane, so here() finds your files.
  5. Render it with the Render button (or Cmd + Shift + K on Mac / Ctrl + Shift + K on PC). This makes an .html file next to your .qmd.
  6. Submit both files, the .qmd and the .html, to that week’s practice assignment on Brightspace.
WarningIf your render fails

Any code question you left blank is set to #| eval: false in the download, and any “fix the error” question you haven’t gotten right yet gets #| error: true, so neither will stop the render. But if one of your other answers has an error, the render will stop at that chunk. Read the error message (Lesson 9 helps!):

  • If it says could not find function, the package that function comes from isn’t loaded in the file. Add it to the pacman::p_load() line in the Load packages chunk at the top of your file (Practice 2 and later have one). Loading it in the Console doesn’t count, because rendering starts fresh.
  • Otherwise, fix the answer, or add #| eval: false as the first line of that chunk, and render again.

If you’re still stuck, submit the .qmd and message me on Slack.

AI Use Statement

Using AI is not required in this class. Every practice page has an AI Use Statement box near the end. If you used an AI tool (ChatGPT, Claude, Copilot, Gemini, an RStudio assistant, etc.), say which tool, what you used it for, and which questions. If you didn’t, just select “I did not use AI.” Either way, it goes at the top of your downloaded .qmd.

For practice, AI can help you understand (explain an error or a concept, explain what a function does, check an answer you already worked out), but it should not do the problem for you. Check the table of allowed uses in the Generative AI Policy before using it.

Getting help

  • Slack is the best place for questions! Your classmates can help, and I answer there too (usually within 24 hours on weekdays).
  • Office hours are a great place to work on practice, even if you don’t have a specific question.
  • Each practice page links to that week’s lesson videos and slides at the top.

Get started

Pick a practice from the Practice Exercises menu above, or jump straight to Practice 1.

You can see which exercises you’ve finished on the My Progress page (tracked in your own browser only).