In this video, I'd like to talk about DataFrames, another data structure type in R. It's nothing more than a table that you might see in an Excel spreadsheet or something like that. But let's build one. The first line here, in this code, there is a bunch of family names. It's a column vector and the names are creatively dad, mom, bro, sis and dog. So let's create that vector. If we take a look at it, we can see there's the column vector. Similarly, we have the credit column vector of their ages. We can take a look. There they are, and their genders, and their family weights. So now, I have these four columns. One is their names, one are the ages, one is a column for their genders, and their weights. So this is some data that you might typically find. I'm going to create a DataFrame. To create a DataFrame, you need this Dataframe open print and then the names of each of the column that you're going to put in there. Now, I'm going to name the DataFrame, the family. So let's run that line of code. There it is. Now, we can actually take a look at it and you can see there it looks like almost like an Excel spreadsheet. The column names are at the top. There they are. Here are the names, there's their corresponding ages, their genders, and their weights. If you come across in someone else's code or something some data structure you're unfamiliar with, you can use this str command which stands for structure. I can even put that on the comments here, structure. That will tell you what kind of data you have. So here we did structure of the family, and you can see that there are five observations of four variables and it's listed them out. Let me go below here, the structure of maybe the weights, just that column vector famweights. You can see here it's a numerical column vector ranging from one to five elements and there are the actual values. So structure command tells you a little bit about the data that you're working with. If you wanted to access just one of the columns in a DataFrame, you can use this dollar sign name notation. So in the structure command, you see the name is the family and then you see dollar family names, family ages etc. If you wanted to reference that, you can do something like the family$, and let's get the ages. There they are and there's the column vector. Now, we can do things with that like calculate the mean. I already have the command up here. What is the mean or what is the average age in the family? There you have it. One thing you need to be able to do when you have a table is to be able to access a row, or column, or an individual cell. There are different ways of addressing each of those components. Here's a pre-loaded dataset in R. It's called mtcars. Mt stands for motor trends Magazine, mtcars. Here's a DataFrame. It has the model of the car, miles per gallon, cylinder displacement etc. We might want to look at the structure, is this a dataframe? There you go. It's a DataFrame, it has 32 observations of 11 variables in this case. If we just wanted to get the miles per gallon column like I showed you in the family example, that would be $mpg. There they are. If I wanted to get just the first column, I use this notation square bracket, something comma something. So let's look at line 10. This is Row 1, Column 2. So if I run that line of code, I get the value of six which is Row 1 Column 2, it's that value there. If I want to just the first column, I put nothing in that first element before the comma and just say the first column. There you go. That happens to be the same as the column for miles per gallon. That's the first column. If I wanted to get the column weights, there they are, mtcars$weght. There they are. If I wanted the sixth column, I can do that. If I wanted the first row. So now, I'm switching square bracket, row one, give me all the columns in the first row. There they are. In this case, this DataFrame does have some labels, so we can do it by the label or the row. There you have it. That basically will help you get around the datasets. Generally speaking for this class, just give me the column. So these first set of commands are what you really need to know, either in the name of the column. So DataFrame name and column name. If you're used to Excel that would be your Excel file name and then your column name, or and then just get it picking out the individual columns. That wraps it up for DataFrames.