Logic and Control Flow

Week 05, Spring 2022

Summary

This week we will introduce some programming fundamentals: comparison and Boolean operators, control flow, and iteration.

Learning Objectives

After completing this week, you are expected to be able to:

  • Use comparison operators and related functions to create logical vectors.
  • Use Boolean operators to perform operations on logical vectors.
  • Combine comparison and Boolean operators to perform logical subsetting.
  • Use if and else statements to conditionally evaluate R expressions.
  • Use ifelse as a vectorized alternative to if and else statements.
  • Use lapply and related functions to iterate over the elements of a vector.
  • Use for and while loops to repeatedly evaluate R expressions.
  • Avoid common pitfalls when using loops in R.

Reading

Link Source
Logical Operations Atomic R
Control Flow Atomic R
Iteration Atomic R

Video

Title Link Mirror
5.1 - Welcome to Week 05 5.1 - YouTube 5.1 - ClassTranscribe
5.2 - Logical Operations 5.2 - YouTube 5.2 - ClassTranscribe
5.3 - Control Flow 5.3 - YouTube 5.3 - ClassTranscribe
5.4 - Iteration 5.4 - YouTube 5.4 - ClassTranscribe
5.5 - Lab 04 5.5 - YouTube 5.5 - ClassTranscribe

Assignments

Assignment Deadline Credit
Lab 03 Thursday, February 16 100%
Quiz 03 Thursday, February 16 105%
Lab 04 Thursday, February 23 100%
Quiz 04 Thursday, February 23 105%

Office Hours

Staff and Link Day Time
Zoom with Abdi Tuesday 4:00 PM - 5:00 PM
Zoom with Mallory Wednesday 9:00 AM - 10:00 AM
Zoom with Zhiyuan Wednesday 4:00 PM - 5:00 PM
Zoom with Dave Wednesday 5:00 PM - 7:00 PM
Zoom with Mallory Thursday 1:15 PM - 2:15 PM
Zoom with Abdi Thursday 3:00 PM - 4:00 PM
Zoom with Zhiyuan Thursday 4:00 PM - 5:00 PM
Discussion Forum Any! Any!