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

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