In this lecture, I'm going to talk about column vectors in R. Column vectors are another basic datatype in R that'll help us store data and be able to manipulate data. The concept of a column vector is not too hard, I'm sure you've seen it before. Here in Microsoft Excel, I have a column of weights. I call the column wts for weights, and I have some weights of objects ranging from 75 at the bottom to a maximum of 280 pounds or kilograms or whatever they may be. So here's some weights, and we might want to create something similar in R. So it's on this Line 2 here. The column vector name is wts. You still have that less-than sign hyphen for the assignment operator, and to create a column vector, you use C, open parentheses, and there's the whole bunch of numbers there, that data 214, 226 etc., down to 75, close parent. That's how you create a column vector. So lets do that. I execute the code. It shows up in my global environment. There it is. I can also type in wts, and there it is. It's listed out, 214, 226, 280 etc. One thing to note, I can finally talk about this square bracket one item here. If I created just a scalar variable, x equals 4 and I show x, I have that square bracket one. In fact, a scalar variable is a column vector with only one element in it, and this is telling you which element it is in the column vector. So here I am in Excel, and 214 is the first element in the column vector. 226 is the second element in the column vector, and so forth. Seventy five is the last element or the eighth element in the column vector. If we go over to RStudio, we can see 214, 226 etc. If I wanted to just get the 226 pounds, wts square bracket two, I can access that. So there it is. I can even put it into another variable y. Y is wts square bracket 2 plus 5, and you can see y is now a value of 231. If I wanted to access more than just that second cell, if I want to get maybe the second through fourth cell, it would be wts square bracket two colon four, and there they are. This square bracket one on the response will tell you this is the first element. If it runs over, you will see the next number. So here I've accessed the second through fourth variables of the weights and I get 226, 280, 185, which we can verify here two through four, 226, 280 and 185, so that works. This square bracket one is the address of your column vector. So here this is the first element, this is your second element, this is your third element etc. If it wraps around, you'll see the address of the bigger vector. So let's create a big vector, and I'm going to call it big vector, and I'm going to use a random number generator. Let's create 100 random numbers. If I want to look at big vector now, you can see that here the square bracket one, this is the first element, 1 minus 1.67 etc., that's the first element. Then we have here a square bracket 10, this item here is the tenth element, and so forth until we get the hundredth element. So that's what this addressing here is. The next thing I want to talk about are some basic commands that we can use on a vector. I have them here in Lines 6 through 10. The first is we can get a summary of the weights. Here are your descriptive statistics, the minimum value, the maximum value, the mean, the median, and the quartile ranges. If I wanted just the mean, I could do that with the mean command. There it is, and the variance and the standard deviation as well. We might want to manipulate some of the data within a vector. So up above, I showed you y is equal to wts weights, the second element plus five. Wts, the second element plus five. But note that's not being stored anywhere. I can store it in another variable y, which I did up above or I can store it back into that same location by saying wts two is assignment operator, wts to plus five. So keep an eye on wts two which is 226. I'm going to add five to it and essentially I might take it out of that box, add five and then put it back into that variable. There you can see it, and now if I look at wts, you can see that the second element has changed. We can also manipulate all the values within a column vector, unhide. So for example, Sam wanted to multiply this column, this is my original column vector. Note I've changed that second one, added five to it. But say I wanted to multiply by three, and these would be the values. That's very simple to do. We just go wts, star for multiplication three, and there they are. Again I can put that back into that same column vector or I could put it into a new column vector. So let's do that. Let's call it wts two or let's say times three is wts times three, and there you have it. We can inspect the value of it, and there it is. Okay. We can also manipulate two column vectors. So here's a column vector here that I've created, and I've just created a sequence of numbers one through eight. I've named it x2, and I'm going to add the two together so that the corresponding entries add up. So here 214 plus 1 is 215. 226 plus 2 is 228 etc. Note that I did change the value of that second element. So I'm going to create a column vector x2, here it is in line four, let me run that. X2 is a column vector; one, two, three, four, five, six, seven, eight, and now I can do something like wts plus x2. Run that, there it is, and now the corresponding entries have added up. That's how you manipulate column vectors. You can all see is multiplication and division. If you're unsure of how these arithmetic operators will behave, just create a small subset like I did and test it out for yourself. One thing to note is that you want to make sure that your column vectors are the same length. R does have special handling techniques for column vectors of different techniques which are beyond the scope of this video and this class. So if you're interested, you can look up the documentation. But for now, and in most cases in real life, column vectors should be about the same length, and that wraps up column vectors.