πŸ—“οΈ Week 02 – Day 01: Neat functions, testing and debugging

What good code looks like and how to test it

Author
Published

17 July 2023

Learn to spot opportunities to write functions and how to write them well. We’ll also learn how to test our code and how to debug it when things go wrong.

πŸ‘¨β€πŸ« Lecture Notes

Today we have a mix of slides and practical coding exercises.

πŸŽ₯ Looking for lecture recordings? You can only find those on Moodle.

1st Hour - Debugging & Refactoring

Either click on the slide area below or click here to view it in fullscreen. Use your keypad to navigate the slides.

2nd Hour - R package, testing and documentation

Let’s create an R package together. We’ll use it to organise our code to adhere to the R package convention.

We will practice writing functions and testing them, then we will see how to document and lint our code.

3rd Hour - 🦸 Super Tech Support

I will be available to help you apply these best practices into your midterm assignment code.

References

Burns, Patrick. 2011. The R Inferno. Second edition (2011 April 30). Place of publication not identified: Lulu Com. https://www.burns-stat.com/documents/books/the-r-inferno/.
Peng, Roger D. 2014. R Programming for Data Science. Victoria, British Columbia, Canada: Leanpub. https://bookdown.org/rdpeng/rprogdatascience/.
Wickham, Hadley. 2019. Advanced R. Second edition. Boca Raton: CRC Press/Taylor & Francis Group. https://adv-r.hadley.nz.