Course Material for PhD Course on Advanced R Programming
Course description
This course is a five-day intensive PhD level course designed for intermediate R users who want to take their skills to the next level. The course covers a range of topics, including project documentation, workflow optimization, ensuring reproducibility, data cleaning and manipulation, advanced plotting, advanced programming functions, and building websites with R.
Importantly, this means this course is not primarily a statistics course, but rather a programming course, where participants learn helpful and important techniques for writing cleaner, more readable, more robust, and potentially faster code.
Overall, the course is designed to provide participants with a comprehensive understanding of advanced R programming techniques, and to give them the skills and knowledge they need to use R effectively in their own projects. By the end of the course, participants will have a solid foundation in advanced R programming and will be able to use R to clean, manipulate, visualize, and analyze data, and to build custom functions and interactive web applications. This will allow them to get through the tedious parts of working with data faster, have more time to explore and analyze, as well as widen their horizon of what is possible in R. The course is also meant as a space for participants to explore and work with their own data, share struggles with the group, and learn together.
The course follows a five day structure, with each day consisting of 5 hours each that are divided in lecture style presentations, and hands-on exercise sessions.
Learning objectives
After this course, participants will be able to:
- Clean and manipulate data efficiently, making use of advanced functions from the tidyverse and purrr packages
- Write own functions using advanced concepts such as non-standard evaluation
- Use Markov-chain-monte-carlo simulation to conduct power analyses
- Use rmarkdown and quarto to output reproducible research reports and interactive websites
- Create clear and visually appealing plots
Please note
This course ran from 12.06.2023-16.06.2023 at the Department of Political Science, Aarhus University.
I am planning to hold this course again in the future. If you would like to attend this course in the future, or invite me to host it at your own institution, please reach out.
Course materials
Below are links to the slides I used for the course. Slides are built using Quarto and Reveal.js.
To download these materials, please head over to the github repository.
The course builds upon a host of amazing free books and tutorials from the R community. Thank you to all who provide their material online for free! Here is a non-complete list of sources used:
- Bryan, J., Hester, J., Pileggi, S., Aja D. E., What They Forgot to Teach You About R (https://rstats.wtf/)
- Ismay, C. Kim, A. Y., A Modern Dive into R and the Tidyverse (https://moderndive.com/index.html)
- Rapp, A., diverse blog posts and tutorials: https://albert-rapp.de/
- Scherer, C., graphic design with ggplot2: https://rstudio-conf-2022.github.io/ggplot2-graphic-design/
- Wickham, H. Grolemund, G., R for data science (second edition – https://r4ds.hadley.nz/)
- Wickham, H., Advanced R (second edition https://adv-r.hadley.nz/)
- Xie, Yihui. 2016. Bookdown: Authoring Books and Technical Documents with R Markdown. Boca Raton, Florida: Chapman; Hall/CRC, (https://github.com/rstudio/bookdown).
Day 1: Workflow, Organization, and Reproducibility
Day 2: Tidyverse basics and advanced features
Day 3: Plotting
Day 4: Functions and Purrr
Day 5: Building a website with Quarto
Schedule Overview
|
Monday |
Tuesday |
Wednesday |
Thursday |
Friday |
09:15 – 10:00 |
Introduction |
Recap Tidy Data & Tidyverse |
ChatGPT & R (guest lecture by Julian Schüssler) |
Defining Functions |
Build your own website with quarto |
10:15 – 11:00 |
Project setup and general workflow |
Advanced Tidyverse concepts and practice |
ggplot Recap |
PURRR & anonymous functions |
|
11:15 – 12:00 |
Good Code |
Advanced ggplot functionalities & packages |
Tidy Simulations |
Intro to Github and version control |
|
12:00 – 12:45 |
Lunch |
||||
12:45 – 13:45 |
Reproducible documents with rmarkdown / quarto |
Regular Expressions |
Exercise: |
Exercise: simulation / work on your own code |
Host your website via github |
14:00 – 15:00 |
Exercise:
Reproducible Documents |
Exercise: Bring your own problem / clean your own data |
End early |
License
This work is licensed under a Creative Commons Attribution 4.0 International License.