Conditional mutating, case_when | Data untangled: transforming and cleaning data with R (lesson 4)

preview_player
Показать описание
👋 LESSON MATERIALS 🛑

Get the data, scripts, PDF notes and quizzes for this lesson from our website:

Chapters
00:00 Intro
02:11 Datasets
04:15 Introducing case_when
09:31 The TRUE default argument
14:34 Keeping default values of a variable
19:02 Multiple conditions, single variable
24:23 Multiple conditions, multiple variables
29:11 Order of priority of conditions
41:00 Binary conditions: dplyr::if_else()
43:35 Wrap up

Learning objectives
1. You can transform or create new variables based on conditions using dplyr::case_when()
2. You know how to use the TRUE condition in case_when() to match unmatched cases.
3. You can handle NA values in case_when() transformations.
4. You understand how to keep the default values of a variable in a case_when() formula
5. You can write case_when() conditions involving multiple comparators and multiple variables.
6. You understand case_when() conditions priority order.
7. You can use dplyr::if_else() for binary conditional assignment.

----------------

And follow us on social media to get the latest updates!
Рекомендации по теме
Комментарии
Автор

Thank you for the video! Just one (very silly) question: In your examples, I noticed that dataframes are not assigned back to themselves (or to new dataframes). I see this same style reflected in the ?case_when() examples. However, when you run your code, the results are printed below. When I copy this code, I either get a convoluted message about the tibble being used as the dataframe or nothing happens at all. Is this style just convention when presenting examples? Should we be assigning the data frame back to itself before beginning the pipe (i.e., df <- df |> …)? Thank you!

markelov
Автор

Kindly attach link to the dataset used

labanlangat
Автор

A talented speaker in a step by step explanation

jamalwadimd