 Okay, in this section, we're going to introduce you to sub-setting vectors. And sub-setting is a technique used to extract specific elements from a vector. So we're going to start by creating a new section. So the way that we do sub-setting is with square brackets. So the first thing that we're going to do is use our previous variable, respondent wall types. And then inside the square brackets, we're going to give the index, in other words, the position within the vector of the element that we want to extract. So in the first case, let's choose one that doesn't repeat just so we know that we're extracting the right one. So then the third element, we have burnt bricks. So let's go ahead and put in the square brackets of three. When we do that in a console, you'll see that burnt bricks was extracted. Okay, so we know that we did it right. You can also do the same technique using multiple indices. And the way that you do that is with the combined function inside square brackets. So in this case, if we wanted to extract O3 and O4, we just put it in the square brackets using the combined function. And when we do that, you can see that both of those elements now have been extracted and returned in our console. You can also subset a vector using a logical test, and this is called conditional subsetting. So let's start a new section header, call that one conditional subsetting. So in this case, instead of actually specifying the index of the value that you want to extract, you're going to use either true or false values to indicate whether or not you want those values returned. And so in the case of our household members variable, just to remind you of what is contained in that vector, you can just run that and see that that's got our four elements 2,3,4,1. So again, using the combined function inside square brackets, if we were to throw in here a collection of booleans or true-false values, we're basically telling R to return the first, third, and fourth value in that vector. OK, and you can see in the console that it executed properly. Now this is a bit strange. You might wonder what the use of that is. Well, typically this would be used as you would basically feed the output of a previous logical test into the subsetting function. And then you can return values, for instance, that were above or below a certain threshold or basically satisfied some logical criteria that you specified. So let me show you how this works in an example. If we take our HHMembers variable, and we're just going to run a logical test, we're going to say HHMembers greater than 2, and we want to return those values. As you see, the output is a vector consisting only of boolean values here, false, true, true, false. This just indicates that the values in the second and third positions both satisfy that condition while the first and last values don't satisfy that condition. And now by embedding those two functions, so just to show you how this works, copying the previous function or logical test and inserting it now in the square brackets, we can subset the values within that vector that satisfy that logical test. And sure enough, when we run that, R returns the only two values that are greater than 2. And it should match, again, the index positions from that previous vector. You can see that the second and third indices both satisfy the condition and the first and fourth were excluded because they did not satisfy that condition. You can also combine logical tests within a single subsetting function. The way that you would do that is just using additional logical operators. So in this case, we're going to tell R that we're interested in all the values that are less than 2 or using this OR operator here, which is just this vertical line, which is right above the Enter key on your keyboard. And also that are greater than, when we return that now, four and one are both returned because four is greater than three and one is less than two, whereas the value three and two are both excluded because those fail the logical test that we specified. So you can do these same tests using other logical operators as well. I'll show you another example here where we're using an ampersand instead of the OR. So in the previous example where we're saying it can satisfy either of those conditions, in this case, we're saying it has to specify both of those conditions. And now if you think about this, there are going to be no examples of values within this vector that can satisfy both of these conditions. These are mutually exclusive. It can't be both less than two and greater than three. So the result we get is this empty set. Okay, you can just read this basically as an error. There are no values that are returned that satisfy those two conditions. Likewise, if we wanted to be more inclusive, we can use the less than or equal to sign or the greater than or equal to sign. And now we have everything satisfies those criteria because again, all of our values are either less than or equal to two or greater than or equal to three. And just a quick reminder that if you wanted to use the equal to operator in R, that's the double equal sign. Just one of these would be equivalent to the assignment operator that we used earlier. And that's not what you want to do. So in the context of this previous example, you would want to use double equal sign. Okay, and now we're saying only those values that are less than or equal to two or equal to three.