From the course: Learning the R Tidyverse
Unlock the full course today
Join today to access over 24,100 courses taught by industry experts.
Solution: Rewrite this code to use the pipe of your choice - R Tutorial
From the course: Learning the R Tidyverse
Solution: Rewrite this code to use the pipe of your choice
(bright upbeat music) - [Instructor] Okay, let's get started with solving this challenge. I'm in 09_12b and I've got my solution.R script up. And this is the same code as you had in your challenge script. So, I'm going to solve this the hard way. I'm going to translate the codes into pipe code. So I'm going to load the tidyverse, so that I have all of the functions and the pipe. And then, what I need to do is I need to find the most deeply nested part of the code, and that's this bit here. So, I can see here that I've got msleep. Let's copy this. Let's paste it down here. And actually, let's take msleep and let's put that here so that the dataset we're using is clear from the beginning. I'll use the keyboard shortcut to insert the pipe. I'm using the magrittr pipe, but feel free to use the base R pipe if you want to. Now, let's use the Delete key and then Enter to get the indentation right. We'll get rid of that comma that we don't need anymore, and we can put all of this on the same…
Contents
-
-
-
What is the tidyverse?2m 22s
-
Installing, loading, and working with the tidyverse packages5m 1s
-
(Locked)
Introducing data.frame and tibbles8m 34s
-
What are %>% and |> for in the tidyverse3m 46s
-
(Locked)
Using the %>% pipe in your code5m
-
(Locked)
Using the |> pipe in your code6m 18s
-
(Locked)
Datasets built into the tidyverse packages3m 15s
-
(Locked)
Using the select() function to obtain columns from data4m 23s
-
(Locked)
Using the filter() function to filter data by conditions6m 10s
-
(Locked)
Using the mutate() function to modify and add columns4m
-
(Locked)
Challenge: Rewrite this code to use the pipe of your choice2m 38s
-
(Locked)
Solution: Rewrite this code to use the pipe of your choice3m 19s
-
-
-
-
-
-
-