5.4 Quiz answers

  • if works with scalars; ifelse() works with vectors.

  • When x is TRUE, y will be 3; when FALSE, y will be NULL; when NA the if statement will throw an error.

  • This switch() statement makes use of fall-through so it will return 2. See details in Section 5.2.3.