Week 2

This week will be our heaviest content-wise, as we’re aiming to give you a brief overview of three of the most important (but somewhat difficult) tools in the essential programming toolbox. We don’t expect you to have a perfect understanding of all these tools after just this session, but we encourage you to revisit this content as needed, and practice these skills, with both our suggested practice problems and also in your own work. A reminder that the best way to become proficient at any programming task is to PRACTICE it.

Functions

Functions are the building blocks of well-written programs in R, and indeed most other OOP languages. A function allows you to perform the same actions over and over again with different inputs, while maintaining a consistent method, and avoiding error propagation that comes with copying and pasting code.

For Loops

Asking R to iterate (or ‘loop’) over a particular set of functions a number of times is a basic and important functionality that is used commonly. There are a variety of looping actions, and they can involve a series of more complex sub-arguments, but here we cover the broad concept of loops, as well as the most common structures, the for loop.

Logical Operators & If-statements

A near-universal programming concept is to ask your computer to do something (i.e. complete a statement), but only if a particular condition applies. This simple but powerful concept allows us to control exactly when particular actions occur in a script, and can be used in tandem with the other concepts covered this week to achieve a particular programming task in a robust, and consistent manner.

We were hoping to cover logical operators in our first week, but unfortunately we ran out of time. Here is a video that covers it briefly. This concept is important, as If-Statements rely on logical operators to run properly.

Logical Operators

If Statements


Content Summary

Please click here to fill out the post-session feedback form here! We take your feedback into account in real time, so any changes we can make to help you learn better next week we will make!