 Statistics and Excel. Correlation, Baseball Statistics. Get ready, taking a deep breath, holding it in for 10 seconds, looking forward to a smooth, soothing Excel. Here we are in Excel. If you don't have access to this workbook, that's okay because we'll basically build this from a blank worksheet. But if you do have access, there's three tabs down below. Example, practice blank. Example, in essence, answer key. Practice tab, having pre-formatted cells so you can get to the heart of the practice problem. The blank tab, blank worksheet so we can practice formatting these cells within Excel as we work through the practice problem. Let's go to the example tab to get an idea of what we will be doing, where we will be going. We're looking at correlation once again when we're thinking about two different data sets to see if there's a mathematical relationship between them. Are they moving together in some way, shape, or form in other words? If there is a mathematical relationship, the next logical question would be, is there a cause-and-effect relationship? If there is a cause-and-effect relationship, the next logical question would be, what's the causal factor in that relationship? This time we're going to be pulling Baseball Statistics data and we'll compare a couple things from it. We'll trim down our data set to start off with and then we're going to be looking at the age versus the batting average doing our correlations, calculations from that data set and then we'll do another one looking at the correlation between the batting average and the RBI. So let's go back to the left. Let's go to the blank tab. We're going to pull our data set. I'm just going to look up Baseball Statistics. I find Baseball Statistics at Baseball Reference has some information for us. I'm looking at the batting averages for 2022 and I'm going to see what they have for us down here. So they have it by team. I don't want it by team. I want it by player. So I'm going to go to the stats by player and then in this dropdown, they say we can drop it down and pull this in. I don't want to pick the Excel workbook because it gets limited to 500 lines and we want all the lines. So I'm going to make it into a CSV format and it gives our CSV information down below, which is a comma deliminated format. And then I could just copy all this and I should be able to just copy and paste this into our Excel worksheet, hopefully without giving us a virus or anything. I'm trusting the site here. It's going to be just good data right here. We're going to copy this whole thing. I'm going to put this over in our worksheet in A1. Right click and paste it. Let's paste it. Either way is fine. I'm going to hold control, scroll down. Notice it's all in column one here and it's a mess. But I want to transfer it from a comma deliminated data to a table. So to do that, I'm just going to keep that first column highlighted because everything is in the first column. We're going to go to our data up top and we want to go to the data tools and then text two columns tool. Text two columns. I'm going to say it's going to be deliminated. Delimitator charters such as commas. Let's keep that. And then I want to deliminate it with a comma. That's the deliminating factor, not the tabs. And then down here you can see it's spacing it out like it looks like it should be. So I'm going to say OK and then finish it. Finish it. And so there we have it. Now I'm going to call this our data tab. And I'm actually going to make a separate data tab from the one that we're going to be working in because we might need to do a little bit more cleaning up of the data from this tab. So I'm going to double click down here and call it the data blank tab. And so there we have that. And so that looks good. The headers, maybe I'll go up top and make this the header column by going into the home tab font and insert. And if I go all the way to the bottom by hitting control shift down, let's do it over here, control shift down. Then this last row, they give me a total. I don't really want the total down here. I don't think I did this last time and I kept the totals in there, which wasn't what I wanted to do. I'll just delete the totals down here and so we just have the data. OK, so then I'm going to go back up top and we're going to say let's insert a table. Insert tables and I'm just going to insert the table here. And so there is our information. So we've got the name, we've got the age and so on and so forth. So what I want to think about is the batting average. That's going to be how many times people get on base in essence. What's the percentage of times that they get on base? And let's see if there's a correlation between that and their age over here. So let's pick those two up. So I'm going to pick up, let's add another tab down here. I'm just clicking on the plus button. I'm going to double click on the tab and call it a blank tab. And then I'll just pull in my data and we'll pull it into this blank tab. So I'm going to go back to our data tab. I'm going to select the entire column of B, which has our names. The entire column of C, which has the ages. And then over here with the batting averages over here, we're going to copy that all that copy that. And let's go on over to our blank tab and just paste it on down in column A. We're just going to paste it on down. I think we could just paste it normal and it'll give us our formatting that's fine. I'm going to hold control and scroll up. So there is our data. Now I'm going to format the entire worksheet first and then I'll go back into your noting that these are decimals and these have no decimals. So I'm going to format the entire worksheet and then reformat these two columns to an appropriate formatting. So I'm going to select the entire worksheet. I'm going to right click on it and we're going to say that let's format the cells. And I like to make it currency, negative numbers, bracketed, no dollar sign. I'm going to remove the decimals and then add them back as needed. Removing the decimals okay. And then I'll add the decimals back to this column because we need them in here clearly because that's what the batting average is represented as in this data set. So home tab number group, adding some decimals, decimalizing it. I'm also going to make the entire thing bold because we like to work in the bold. Okay, because it's better for the screencast. You don't have to do that if you don't want to. So then let's go ahead and do some of our statistical calculations which we know by heart at this point in time with our actual data. But before we do, let's clean up our data a little bit. Let's go to the insert tab up top. Let's go to the tables and add a table. I'm going to put a table around this whole thing. Now note that when we look at this data, the batting average has some blank stuff in it. And also if people didn't have that many at bats, then you might want to remove the batting averages for those items as well. So I might sort this now by the batting average and I'm going to say A to Z and then everything.