 All right, buckle in everyone, because you're all about to be on a wild ride. This is going to be the first in my videos on R and statistics. So if you don't know what R is, I should go ahead and say R is, technically it's a computer language, but it's more like an omnipotent, you know, statistics in math and graph making and cell sheet and everything else command line interface. It's one of the most amazing tools you could possibly run across. It's fun to play with, fun to figure things out, but it's also extremely powerful. And it's also very desired if you're the kind of person who wants a job in life. People are using R everywhere nowadays. It's popularity is booming. They use it all over industry. We use it all over academia, stuff like this. It's one of the greatest tools you can possibly learn anywhere on the computer. So R, so, well, I'll go ahead and say to install R, you can go to r-project.org, which is this side right here and you can download it. If you, of course, you're using Linux, you can usually just install it on the command line or something like that. But yeah, so in this video, I'm going to talk about, I'm not going to talk about anything too deep about R. I'm just going to talk about why I think it's important to learn it or why I think it's nice to learn it. You don't have to. But, you know, one of, so I'm going to talk about the reasons it's good and also going to do some basics, really mathematical manipulation, doing basic arithmetic just to get a feel for how R is. So one of the reasons I want to do this series is R is so powerful in that a lot of people who use it, they know how to do a couple functions because these functions are really powerful and they do a whole lot. But they don't necessarily have an intuition for how R works, which is a shame because it's a very cleverly programmed language for doing what it does. So again, in this video, we're just going to talk about the math and sort of the basic manipulation in R. And later on in the series, I'll talk about doing fancy linear models and, you know, more things like that. So anyway, this is R. So once you install it, you can just open up any kind of terminal, type in R. It usually has to be capital R depending on what operating system you're using. But you can jump into here. I just control L to get rid of the entry message or whatever. So once you're in here, you can do pretty much any bit of arbitrary arithmetic. So 5 plus 10 is 15. 60 times 9 is 540. You know, 41 divided by 5 is 8.2, stuff like that. So none of this is going to be too special for anyone who's used another computing language. But as we go on, as we get to more advanced data frames, you're going to see really, I guess, very unique choices made in the R language. But just know, of course, you can do basic arithmetic. Now notice this thing here, this little thing in the bracket. So R, sometimes you're going to be running R commands that return a huge number of data points. So they'll take up multiple lines. So this thing here, these things appear at the beginning of lines. They just mean this is the first data point. That's what that means. So don't sweat what that is. That's all it is. So yeah, you can do basic math pretty much as you would expect. You can of course use, you know, parins for order of operations or something like that. So we can do something like this to get the answer we want. All the basic stuff you expect, so like 6 raised to the 7th, etc., etc. So one nice thing that R has just right off the bat, let's say we have a really big number that we return in some kind of function. And I want to perform some kind of operation on this number. So you can't, well, it's too long to type out. Let's say, well, it's only six, you know, characters, but who cares? I'm too lazy to type it out. One thing you can do is type in this. You can just say last value. And this at all times in places, actually I guess this is more than six characters. But if you're returning something that's 40 characters, it makes sense. But period, last value, what this is, it is really just referring to whatever the last thing you return was. So last value times 8 is actually just this number times 8. Yeah, it makes more sense when you have something that's like 40 characters long, but there's probably a way of shortening it, actually. But anyway, so that's basic arithmetic. You guys know how to do it. Lots of other computing languages have that. Another thing that R has that most computing languages do have as well is, of course, variable assignments. So I can say something like x equals 5. Now, if we put in x, we get 5. R also is sort of unique in that you can use arrows to create variables. So if I say something like this, y and then 100 pointing to it, that actually assigns 100 to y. In fact, you can do it in the reverse way. So let's say 100 goes to z. Now, z is also 100. So you can assign variables in either way. In fact, you can do this. You can assign 100 to both a and b at the same time. Aren't many situations where I need to do this, but you can. I'm probably a bad person, but I actually use equals a lot. But there are actually some places where you want to use arrow signs since equals, you can only put the variable on the left arrow signs. You can do either. So in addition to this, let's say you also have basic greater than less than kind of features, or let's say is a greater than x. That is true because a is 100. x is 0. It is not true if x is greater than a. That is not true. And also let's see. So a and b are both 100. So a equals equals b. That is true. a equals equals x is false. And remember, you have to do two equals here. Otherwise, that'd be variable assignment. So if I just did a equals x, what that would be doing is of course assigning x's value, which is 5 to a. So now a is 5. And of course now a equals equals x. That's true. So you can just play around with this. This is again pretty basic stuff for anyone who's familiar with the computing language, but I just think it's important for people to, you know, you have to pound in the basics so it's all reflex. Okay. So what are some things that are special about r? Now one of the main things that r does that's a little different than other languages is that r has these things called vectors. Vectors work a lot like lists in other languages, but they're very like the way r can manipulate them are very unique. r actually does have lists, but people don't really use them that much. Vectors are weird to have. Okay. So how a vector works in general is you can have just let's say we have a whole bunch of numbers and you put them in the c function. So this thing here, it stands for a combine. If we run this, we will get just, you know, the same series of numbers we put in, but this is technically a vector. In fact, we can assign this vector to x. So now x is this. x is this vector. So vectors, well there are other ways of assigning vectors. Let's say we want to set y to, let's say we want to set y to 1, 2, 3, 4, all the way up until 100 or well let's say 50. That's a fair number. We don't want to have to type that out. So we can actually abbreviate it by just doing this. So 1 colon 50. So now if we return that, you will see we have lots and lots of numbers. Notice also that so here we see two of these bracketed things. So this means this is the first element in the list and this is the second element in the list. It actually got a little confused because I maximized the terminal. It should have one at the beginning of every line, but you know, don't sweat it. That's just what this means. So anyway, so we use the colon to sort of abbreviate how we want, how we want our vector to be formed. You can also, in fact, you can also do something like this. Let's say we want y to be equal to 1 all the way to 50. And then also for some reason we just want 76 to be in there. We can, excuse me, you have to do this. You have to have it in the c function. So that will, as you see here, we have everything all the way up to 50 and then 76, awkwardly at the end all alone. Okay, so that's vector assignment. What's the special about vectors? So let's just recoin x. We'll say it's 1 to 5 or something like that. So the special thing about vectors is that you can do things like this. So I can say something like x times 15. Okay, now what is this going to do in a normal language? Now in a normal language, the most, if you're in a good stable language, you're going to get an error when you see this. Because the language is going to say, okay, you're telling me to do something, you're telling me to take a vector and put it with some kind of arithmetic, telling me to do something with a number. I don't exactly know what to do with that. So I'm going to give you an error. Some languages, I think like Python for example, or I'm pretty sure Python works like this, I'll have to remember, but there are some languages where if you take like a something and multiply it by 15, that's not a number, it'll just put 15 instances of it or something like that. Now what r does is very unique. If I run x times 15, I get this. So what is this? Well, it's every element in the vector multiplied by 15. So that might seem like it, okay, well, that's interesting. That's an interesting design choice. But this is one of the fundamental, I guess, most important things about how r is designed. It's designed so that the elements and vectors and the elements and data frames and other kind of objects in r are first class citizens. You can manipulate them directly. Now in another computing language, if you wanted to get this result from this vector, you would have to do something like, okay, so for, you'd have to write like a for loop that says, okay, for each element in x, perform this operation, print this variable, blah, blah, blah. So, and that would be a pain. But r, again, treats these as first class citizens. So x times 15 is that x plus 15, it's not going to add 15 to the end. It's going to add 15 to each of the elements in the list. Okay, so here's our vector again. Another thing you can do. So let's say, let's make another vector. We'll make it, you know, 54 to just some random numbers that look a lot the same, but whatever. So y is now this vector. Okay, so what happens if we do this x plus y? What's going to happen? Well, we're not going to take y and put it at the end. That doesn't seem very r-like. But it also, like if we're at eight, what are we going to do? Add all the numbers to each of the numbers individually. So what r actually does is it returns something like this. And what this is, just in case it isn't super clear, it is the first element in x plus the first element in y. That's the first element in this. The second element plus the second element is the second element here, etc, etc. So this again is an example of our treating vectors as first class, or the elements in vectors as first class citizens. So there are going to be a lot of times, so let's say you're using Excel and you have a column that you want to divide by another column or something like that. So to do that in Excel, you have to highlight and then you have to do little math things, equals, you know, the sum or whatever. Yeah, forget exactly how it works in Excel. In R, you just have to do this. So when we get to data objects, you can just say I want this column divided by this column. Bam, there it is. It already knows I'm going to go through each one of these individually and divide them by, you know, whichever one. So play around with this. This is sort of quint essentially r. So we've talked about basic math, which is pretty much how you expect. We talked about variables, how you assign variables, how you play around with them, and also vectors. And vectors are going to be where the magic starts and where it happens. And so in the next video, I'm going to talk about basic mathematical functions, or no, statistical functions, I should say statistical functions, because we've talked about playing around with data. How are we actually going to find useful things? How are we going to run useful operations on it? We'll talk about that more in the next video. And then we'll get further on the stuff like doing fancy models, making graphs, all of which is easily within grasp of you now. So anyway, so I'll see you guys next time.