Welcome!

BSTA 526: R Programming for Health Data Science

Meike Niederhausen, PhD

OHSU-PSU School of Public Health

2026-01-08

Welcome to R Programming!

This course introduces you to R in two parts:

Part 1 focuses on working through common tasks in data science:

  • importing data
  • wrangling data
  • visualizing data
  • summarizing data

Part 2 focuses on more advanced topics:

  • joining and merging data tables
  • automating tasks (functions, purrr/for loops),

We might get to:

  • running basic statistical procedures
  • fancy tables in Quarto with kable, gt, and gtsummary
  • advanced Quarto topics

Throughout, we’ll work on concepts of reproducibility by utilizing RStudio project and Quarto document-based workflows as a way of reproducibly sharing our work.

Instructor Information

Instructor

Teaching Assistant

Syllabus

https://niederhausen.github.io/BSTA_526_W26/syllabus.html

Learning Objectives

  1. Understand and utilize R/RStudio, including using Quarto to create reproducible documents of statistical analyses.
  2. Understand basic data types and data structures in R.
  3. Familiarize and load data files (Excel, Comma Separated Value files) into R/Rstudio, with tips on formatting.
  4. Visualize datasets using ggplot2 and understand how to build basic plots using ggplot2 syntax.
  5. Filter and format data in R for use with various routines.
  6. Run and Interpret some basic statistics in R.
  7. Automate repetitive tasks in R, such as loading a folder of files.

If time allows:

  1. Create nice tables in our R markdown reports with gt, gtsummary, and/or kableExtra.

Required Texts and Readings

This course will be drawing on the following online textbooks. These books are online and free, though you can order them as textbooks if you prefer that format.

Grade breakdown

  • Attendance (based on post-class surveys) 5%
  • Homework Assignments 30%
  • Function of the Week 5%
  • Midterm Exam 30%
  • Final Exam 30%

Attendance

  • Regular attendance is expected, but will not be monitored.
  • Classes will be recorded, but I cannot guarantee the in-person format will lend itself to effective recordings.

Post-class surveys

  • 5% of your grade is based on filling out post-class surveys as a way of indicating that you came to class and engaged with the material for that week.
  • You only need to fill out 7 surveys (of the 10 class sessions) for the full 5%.
    • I encourage you to fill out as many surveys as possible to provide feedback on the class though.
  • Please fill out surveys by the following Wednesday at noon.
  • The questions on the survey are:
    • Rating the pace of the class
    • Clearest Point: Which topic of the class was clearest for you?
    • Muddiest Point: Which topic of class was the muddiest (unclear) for you?
    • Anything Else: Anything else you’d like me to know?

Homework

  • Homework will be assigned weekly using Quarto in RStudio.
    • It will be due via Sakai upload Thursdays at 11:55pm the night of the following week’s class (unless otherwise noted).
    • Please turn in both your .qmd and rendered .html file.
  • The homework with the lowest score will be dropped from your homework average.

Late Policy

  • Students get 1 free homework assignment to submit late within 3 days without penalty.
  • Please email the instructor and the TA that you need more time.
  • If you need an accommodation, please email me so I can figure out a way to help you.

Functions of the Week

  • Please choose a function(s) from the Functions of the Week sign-up sheet
    • Link will be posted on Sakai.
  • A Quarto template to format your Function of the Week and presentation will be provided.
  • Functions of the Week presentations will start in week 4.
  • On the sign-up sheet you will choose a week to present your function(s) to the class, as well as the function(s).
  • The presentation should be short, around 5 minutes.
  • If presenting to the class feels prohibitive, you may submit a 5-10 minute screen recording with your voice narrating the presentation, and this will be distributed to the class.

Previous years’ Functions of the Week can be found on the previous class websites:

I will create a similar website for this year’s Functions of the Week. If you do not wish yours to be on the public facing website, just let me know. Alternatively, I can also post it anonymously. See submitted Functions of the Week for this quarter at this link.

Midterm and Final Exams

Artwork by @allison_horst

Artwork by @allison_horst

Words of Encouragement

This was adopted from Andrew Heiss. Thanks!

I promise you can succeed in this class.

Learning R can be difficult at first—it’s like learning a new language, just like Spanish, French, or Chinese. Hadley Wickham—the chief data scientist at RStudio and the author of some amazing R packages you’ll be using like ggplot2made this wise observation:

It’s easy when you start out programming to get really frustrated and think, “Oh it’s me, I’m really stupid,” or, “I’m not made out to program.” But, that is absolutely not the case. Everyone gets frustrated. I still get frustrated occasionally when writing R code. It’s just a natural part of programming. So, it happens to everyone and gets less and less over time. Don’t blame yourself. Just take a break, do something fun, and then come back and try again later.

Even experienced programmers find themselves bashing their heads against seemingly intractable errors. If you’re finding yourself taking way too long hitting your head against a wall and not understanding, take a break, talk to classmates, e-mail me, etc.

LeaRning is Social

Students who work together with other students are often more successful than students who work alone. We are a learning community, and we should help each other to learn.


If you understand something and know someone is struggling with it, try and help them.


If you are struggling, take a breath, try to pinpoint what you are struggling with, and don’t be afraid to ask for help.


Our goal is to be better coders each day, not to be the perfect coder There’s no such thing as a perfect coder. I’ve been using R for over 20 years and still constantly learn new things.

Using AI to learn how to code

Andrew Heiss’ thoughts on this:

However, they’re only useful if you know what you’re doing first. If you skip the learning-the-process-of-writing-code step and just copy/paste output from ChatGPT, you will not learn. You cannot learn. You cannot improve. You will not understand the code.

The only way to gain domain knowledge, data analysis expertise, and coding ability is to struggle. To get errors. To google those errors. To look over the documentation. To copy/paste your own code and adapt it for different purposes. To explore messy datasets. To struggle to clean those datasets. To spend an hour looking for a missing comma.

Use of generative AI for assignments

  • Generative AI tools (such as ChatGPT) can be great resources for learning how to code and/or troubleshoot code that does not work.
  • However, the work you turn in must be your own.
  • Thus it is inappropriate to directly ask AI to provide you with solutions to homework questions or write text that you are submitting in your assignment.

If you do use AI tools to help you with an assignment, these must be cited along with how they were used.