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.

Subsetting

Subsetting

- [Narrator] One of the really impressive features about r is it's ability to slice data with something called sub-setting. It's really important that you learn how to use sub-setting, it'll save you a lot of time. So let's take a look at that. First of all, let's look at the built in data constant called letters. And this is just a list of all the capital letters in the alphabet. I can do a quick sub set by typing in letters. And then a bracket and three. And what that's going to do is give me the third object of letters. I can pull of sets of elements, type in letters and I'll type in a bracket, and three colon five, which produces the third, fourth, and fifth element of letters. There's another way we can do this. Letters, bracket, and let's get three comma 20 colon 25. And what that'll produce is the third, and the 20, 21st, 22nd, 25th elements of letters. You can also exclude selections by typing in, there's letters, that's what we want to search through. And I don't want, that's…

Contents