 Okay, so in this video, we're going to talk about some of the basic statistical functions in R. It's not advanced statistics, but just, you know, the functions you're going to be using on a daily basis to get what you want from data and do all the basic stuff. So we're still sort of getting our C legs, so to speak. We'll talk about more advanced stuff, data frames in the next video. But here we're going to talk about all the functions that you really need to have as a reflex if you're playing around in R and just the kind of stuff that you can generally do. So I'm going to start out just by giving us some data. I'm going to randomly make a data frame of, you know, it's going to be called eBay. And we'll say hypothetically that this is the income we made in an eBay business over several months. So each one of the values in here is monthly income from eBay or something like that. I'm actually going to hide that because we don't need to see it because we're going to be running some functions on it. Okay, so basic stuff. So let's say you're, you know, you got your eBay business and you got to do taxes or something like that. Let's say you want to count up all the money you've made in your eBay business. So you can use the command sum on any vector and that will sum up everything in the vector, simple enough. If you forget how many elements are in that vector or how many months we were earning eBay income, you can actually just type in length. So length six, so that's six months or whatever. And as you would, you can probably guess, you can take sum of eBay and divide it by length of eBay. And that is going to give you what is effectively the average or the mean. So this is the average monthly income from eBay. But of course, R makes everything easier. So they're not going to make you type all that. You can just type mean and you'll see that these are exactly the same. So R theoretically does know exactly what it's doing. So you can also know more specific things about your data, like what is the least amount we earned in a month? What's the minimum? Well, you can run min. What's the maximum number? That's you can run max simple enough. You can also calculate the median, which I don't think it's going to. OK, yeah, it will give us, even though we do have an even number here. So notice, of course, in the situation of median, if there's an odd number, it's going to pick the actual median. Since there's an even number, it takes the two closest values and it averages them. So 230 and 270 just happened to be a very clean number here. So that's some basic stuff. We can also take our data frame. Notice that we're not always increasing in the money we make on eBay. But if hypothetically we want to see all that data sorted by how big it is or how small it is, we can run the sort command. And you'll see now that we're actually we start with the lowest value with men and end up at the maximum value. So you can actually see that this would a change in number. If you want, actually, you can also run the rev command. And what rev does is actually reverses any vector. So if we rev the sort function, what we're doing is taking the now we have the greatest value decreasing to the smallest. Of course, you don't just have to run that on the sort command. You could run rev on the day itself. And what this would be giving us is basically monthly income, but starting at what June, I guess, and then going to January. You might want to do that for some reason. But anyway, so these are some of the basic functions and I'll also say one of the things one of the I don't want to say most important functions, but one of the functions that everyone runs on our whenever they import data is this nice handy thing called summary. Now, summary actually has does a couple things. It gives you the median. It gives you the mean minimum maximum. Also gives you some the first and third quartiles. So just if you want to get a general idea of what your date is looking like, a summary is a good command to play around with. OK, so that said, these are some of the basic commands. Now, you can also, of course, graph things and are very easily. We're not going to talk about the more advanced like Gigi plot and stuff like that in this video. But just so you know, there you can plot things pretty easily. In fact, you can plot them with just the plot command. And there's your plot. Let me give it in my face here for a second. So you'll see by default, well, you'll see down here on the X axis, we have index. So this is basically months, so like January, February, March, whatever. And we have eBay up here. It's labeled as eBay, but this is really just the dollar amount. Now, of course, by default, plot just sort of randomly names these. What it thinks it should not randomly, but it names them what it think they think what it thinks they should be called. But we can rename these. So if I want the X label instead of index, let's say I want that to be month and the Y label, I'm going to call that, you know, dollar income. And you can also change. You can also put a title up here and that's called a main. And we can say, you know, eBay, monthly revenue or something like that. And that will automatically change our graph. So plot is one of the basic graphs. It's really easy to use the, of course, the output isn't super pretty, but, you know, it's nice having if you want to just visualize stuff, if you don't want to use or at least you don't want to get into more advanced stuff like GG plot yet. Now, for any of these commands, I think I might have said it before, but it's important to say it again. And if I did, you can check to see all the specifics by just running question mark and then the command. So this will bring up a manual page that you can scroll through and it'll tell you all the different variables you can give this stuff, you know, so Y label, X label, main title, sub title, all the kind of stuff that you can play with. And this is extremely important, especially like with more advanced stuff. You want to be able to know what exactly the function is doing when you're running it and stuff like that. So this is plot. Another very simple graphing command is hist. This is another one that's pretty important to know, which makes just a histogram of your data. So just to make sure we're all on the same page, right? So what this says is, you know, there are two instances of monthly incomes between 200 and 300 and two instances between 100 and 200, et cetera, et cetera. So it's a histogram. So plot or histogram might be more appropriate for whatever data you're playing with, but of course, both have different ways that you can modify the X and Y values and stuff like that. Now R, as you notice from these commands, R will sort of automatically calculate what it thinks like the scale should be here, but you can like set that automatically. You can ignore outliers. You can do lots of other stuff. Just check the manual for that. Okay. So this has been, oh, there's one other command that I really like that I should throw in just because it's pretty cool. So we have eBay. Let's say you want to know like Delta eBay, like the change, the monthly change in income. So we talked about some eBay and that will sum everything up, but you can also have Diff of eBay. And what Diff does, notice that it's going to return five values and these five values are the difference between each of the two months that are next to each other. So, you know, we, a first month is 121, then you add 109 to get 230. So that's what Diff is. And it's really nice. I mean, if you're, I don't know, calculating GDP and you know, you want to know the change in GDP or something like that or anything, you can do it in any matter of thing. Diff is a really helpful command. I only say that because there's one time I needed to do it and I didn't know the command existed. So I like sort of built it myself and then I realized it was already there. Um, okay. So that, that's about it. These are the basic functions. Again, we're just playing around with vectors so far. So in the next video, we're going to be dealing with data frames, specifically how to play with raw, uh, raw columns and codes, uh, columns and rows and really get the kind of functionality. I think after that video, you're going to be, you're never going to want to use Excel again. Uh, that's the selling point. But anyway, so this has been just an introductory to the, oh, one, one last hemp. If you want to check the, um, uh, excuse me, the, the, uh, fact of variables you have out there, you can just type LS. In fact, now that I'm done, I'm going to remove eBay. I'm going to get rid of it. So now eBay is gone. Okay. So that's it. I hope you guys learned something and I'll see you guys next time.