From e56ccb6d948ff2d52e1f9ba67b6a6620f4909bb0 Mon Sep 17 00:00:00 2001 From: Floris Vanderhaeghe Date: Mon, 29 Jan 2024 02:11:47 +0100 Subject: [PATCH] logicals.qmd: use if_else() in exercises instead of ifelse() (#1622) --- logicals.qmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logicals.qmd b/logicals.qmd index 254b241..7d9fb9c 100644 --- a/logicals.qmd +++ b/logicals.qmd @@ -564,9 +564,9 @@ We don't expect you to memorize these rules, but they should become second natur 1. A number is even if it's divisible by two, which in R you can find out with `x %% 2 == 0`. Use this fact and `if_else()` to determine whether each number between 0 and 20 is even or odd. -2. Given a vector of days like `x <- c("Monday", "Saturday", "Wednesday")`, use an `ifelse()` statement to label them as weekends or weekdays. +2. Given a vector of days like `x <- c("Monday", "Saturday", "Wednesday")`, use an `if_else()` statement to label them as weekends or weekdays. -3. Use `ifelse()` to compute the absolute value of a numeric vector called `x`. +3. Use `if_else()` to compute the absolute value of a numeric vector called `x`. 4. Write a `case_when()` statement that uses the `month` and `day` columns from `flights` to label a selection of important US holidays (e.g., New Years Day, 4th of July, Thanksgiving, and Christmas). First create a logical column that is either `TRUE` or `FALSE`, and then create a character column that either gives the name of the holiday or is `NA`.