From the course: R for Data Science: Lunch Break Lessons

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Pipeline

Pipeline

- [Instructor] If you've used the Tidyverse or seen code from the Tidyverse, you've seen the pipeline operator. That's the percent greater than percent symbol. There are other uses for that package, it's called magrittr. And it contains several operators that you'll find useful. Let's take a look at it. First you install the package, magrittr, and bring it into the library. And we can start with the very simple example of what this looks like. Without the pipeline you do something like this, where you'd create a variable. We'll assign fivenum. Fivenum generates a set of quartiles, one to 23, and you can see now we have a myvar with five numbers in it. And then I'd like to plot that value, so I'll use plot, and I'll put in myvar, and I'm going to plot it against one to five. So there's a plot for us. I can make this simpler by getting rid of the myvar and replacing the right hand side with a pipeline symbol, and then placing plot at the end, getting rid of myvar, and I can even make it…

Contents