课程: R for Data Science: Lunch Break Lessons

免费学习该课程!

今天就开通帐号,24,100 门业界名师课程任您挑!

dplyr: slice and friends

dplyr: slice and friends

- [Instructor] We're talking about dplyr, which is part of the tidyverse, and dplyr is a package that contains many data manipulation tools. A couple of sessions ago, we talked about the select command which allows you to select individual columns. Then we talked about the filter command which allows you to select individual rows. Now we're going to talk about slice and related commands and I've listed these in line four, five, and six. So slice_head and slice_tail will select the first or last rows. Slice_sample gives me randomly selected rows. Slice_min and slice_max select rows with the highest or lowest values of a variable. Let's see what those look like in real life. Of course, the first thing you'll need to do is enable the tidyverse library which I've done in line 9 and 10. And then in line 12, I've set up a slice command using read.csv. You'll notice that I'm not assigning the result to any sort of a vector…

内容