 Probably the best place to start when you're working with any statistics program is basic graphics. So you can get a quick visual impression of what you're dealing with. And the command in R that makes the simplest of all is the default plot command. It's also known as basic x, y plotting for the x and y axes on the graph. And what's neat about ours plot command is that it adapts to data types, and to the number of variables that you're dealing with. Now, it's going to be a lot easier for me to simply show you how this works. So let's try it in R. Just open up the script file and we'll see how we can do some basic visualizations in R. The first thing that we're going to do is load some data sets from the data sets package that comes with our we simply do library data sets. And that loads it up. We're going to use the iris data which I've showed you before and you'll get to see many more times. Let's look at the first few lines. I'll zoom in on that. And what this is is the measurement of the sepal and petal length and width for three species of irises is a very famous data sets about 100 years old. And it's a great way of getting a quick feel for what we're able to do in R. I'll come back to the full window here. And what we're going to do is first get a little information about the plot command to get help on something in R. Just do the question mark and the thing you want help for. Now we're in our studio. So this opens up right here in the help window. And you see we've got the whole set of information here all the parameters and additional links that you can click on and then examples here at the bottom. I'm going to come over here and I'm going to use the command for a categorical variable first and that's the most basic kind of data that we have. And so it's species, which is three different species is what I want to use right here. So I'm going to do plot. And then in the parentheses, you put what it is you want to plot. And what I'm doing here is I'm saying it's in the data set iris that's our data frame, actually. And then the dollar sign says use this variable that's in that data. So that's how you specify the whole thing. And then we get an extremely simple three bar chart, I'll zoom in on it. And what it tells you is that we have three species of iris, setosa, versicolor and virginica. And then we have 50 of each. And so it's nice now that we have balanced group that we have three groups because that might affect some of the analyses that you do. And it's an extremely quick and easy way to begin looking at the data. I'll zoom back out. Now let's look at a quantitative variable. So one that's on an interval or nominal level of measurement. For this one, I'll do petal length. And you see I do the same thing plot and then iris and then petal length. Please note, I'm not telling R that this is now a quantitative variable. On the other hand, it's able to figure that one out by itself. Now, this one's a little bit funny because it's a scatter plot, I'm going to zoom in on it. But the x axis is the index number or the row number in the data set. So that one's really not helpful. It's the variable that's going on the y that's the petal length that you get to see the distribution. On the other hand, you know that we have 50 of each species. And we have the Satosa, and then we have the Versa color, and then we have the virginica. And so you can see that there are group differences on these three things. Now what I'm going to do is I'm going to ask for a specific kind of plot to break it down more explicitly between the two categories. That is, I'm going to put in two variables now, where I have my categorical species, and then a comma and then the petal length, which is my quantitative measurement. I'm going to run that again, you just hit controller command and enter. And this is one that I'm looking for here, let's zoom in on that. Again, you see that it's adapted and it knows, for instance, that the first variable I gave it is categorical. The second one's quantitative. And the most common chart for that is a box plot. And so that's what it automatically chooses to do. And you can see, it's a good plot here, we can see very strong separation between the groups on this particular measurement. I'll zoom back out. And then let's try a quantitative pair. So now I'll do petal length and petal width. So it's going to be a little bit different. I'll run that command. And now this one is a proper scatter plot where we have a measurement across the bottom and a measurement up the side. But you can see that there's a really strong positive association between these two. So not surprisingly, as a petal gets longer, it generally also gets wider. So it just gets bigger overall. And then finally, if I want to run the plot command on the entire data set, the entire data frame, this is what happens, we do plot and then iris. Now we've seen this one in previous examples, but let me zoom in on it. And what it is is an entire matrix of scatter plots of the four quantitative variables. And then we have species, which is kind of funny because it's not labeling them. But it shows us a dot plot for the measurements of each species. And this is a really nice way if you don't have too many variables of getting a very quick, holistic impression of what's going on in your data. And so the point of this is that the default plot command is able to adapt to the number of variables I give it and to the kind of variables I give it. And it makes life really easy. Now I want you to know that it's possible to change the way that these look, I'm going to specify some options. I'm going to do the plot again, the scatter plot, or I say plot. And then in parentheses, I give these two arguments or saying what I want in it. I'm going to say, do the petal length, and do the petal width, and then I'm going to go to another line, I'm just separating with comma. Now if you want to, you can write this all as one really long line, I break it up because I think it makes it a little more readable. I'm going to specify the color and do with call for color. And then I use a hex code. And that code is actually for the red that is used on the data lab homepage. And then pch is for point character. And that is a 19 is a solid circle. Then I'm going to main title on it. And then I'm going to put a label on the x axis and a label on the y axis. So I'm actually going to run those now by doing command or control enter for each line. And you can see it builds up. And when we finish, we got the whole thing, I'll zoom in on it again. And this is the kind of plot that you could actually use in a presentation or possibly in a publication. And so even with the base command, we're able to get really good looking, informative clean graphs. Now what's interesting is that the plot command can do more than just show data, we can actually feed it in formulas. If you want, for instance, to get a cosine, I do plot and then cost is for cosine. And then I give the limit, I go from zero to two times pi because that's relevant for cosine. I click on that and you can see the graph there. It's doing our little cosine curve. I can do an exponential distribution from one to five. And there it is curving up. And I can do D norm, which is for a density of a normal distribution from minus three to plus three. And there's the good old bell curve there on the bottom right. And then we can use the same kinds of options that we used earlier for our scatter plot. Here, I'm going to say do a plot of D norm. So the bell curve from minus three to plus three on the x axis. But now we're going to change the color to red, LWD is for line width, make it thicker, give it a title on the top, a label on the x axis and a label on the y axis. We'll zoom in on that. And so there is my new and improved prettier and presentation ready bell curve that I got with the default plot command in R. And so this is a really flexible and powerful command. Also, it's the base package. And you'll see that we have a lot of other commands that can do even more elaborate things. But this is a great way to start and get a quick impression of your data, see what you're dealing with and shape the analyses that you do subsequently.