Control Structures

2024-02-28

We Have Done

  • Homework 4
    • Data structure conversion: matrix - vector - dataframe

We have read

Control Structures

  • Conditional: if else

    • Use logical statement
  • Loops

    • while loop

      • Update the variable to avoid infinite loop
    • For loop

      • Normally loop over a list

      • Iterate all the values in the list

    • Sometimes either loop does the work

  • Other structures:

    • case_when in tidyverse (really handy!)

    • Control loops: continue/ break/ next

Next Time

  • Midterm

  • Homework resubmission deadline March 5, 6 pm

Homework5

  • Download and save Homework5 raw content

    • Click the link

    • Copy the raw content

    • Save to a Quarto file under Source mode

    • Name the file as 05-Lastname-Firstname.qmd

    • Submit in .qmd file

Homework 5

  • Double check the working directory, so files generated will be read in with the relative path in the following code.

  • Python uses indentation to indicate a block of code, but R uses {}