## Course Outline

• segmentGetting Started (Don't Skip This Part)
• segmentIntroduction to Statistics: A Modeling Approach
• segmentPART I: EXPLORING VARIATION
• segmentChapter 1 - Welcome to Statistics: A Modeling Approach
• segmentChapter 2 - Understanding Data
• segmentChapter 3 - Examining Distributions
• segmentChapter 4 - Explaining Variation
• segmentPART II: MODELING VARIATION
• segmentChapter 5 - A Simple Model
• segmentChapter 6 - Quantifying Error
• segmentChapter 7 - Adding an Explanatory Variable to the Model
• segmentChapter 8 - Models with a Quantitative Explanatory Variable
• segmentPART III: EVALUATING MODELS
• segmentChapter 9 - Distributions of Estimates
• segmentChapter 10 - Confidence Intervals and Their Uses
• segmentChapter 11 - Model Comparison with the F Ratio
• segmentChapter 12 - What You Have Learned
• segmentResources

# 2.0 Understanding Data

## Starting With a Bunch of Numbers

When statisticians talk about variation they refer to a particular kind of variation: variation in data. But variation doesn’t start out as data. Look around; you see people, buildings, trees, light, and so on. And you see lots of variation: no two people look exactly alike, just as no two trees look exactly alike. Statisticians seek to express this variation using numbers, which is where we will start. (In a bit we will discuss where the numbers come from.)

Not all groups of numbers have variation. Take, for example, these numbers: 2, 2, 2, 2, 2, 2, 2, 2, 2. No need to use statistics in this case because there is no variation. You can just look at the numbers and describe them in a phrase: “Nine twos.” If we said: what number best represents this distribution of numbers, you would, almost certainly, say, “Two.”

But take this group of numbers: 2, 1, 3, 3, 2, 3, 1, 2, 1. Now it’s not as easy to describe them, certainly not in a short phrase. And imagine if there were hundreds or thousands of numbers; the challenge would be even greater.

### Seeing Patterns in Numbers

Statisticians have, over the years, invented some ideas and some procedures to help us make sense of bunches of numbers. Here’s a simple example. First, see if you can create a vector to store the numbers 2, 1, 3, 3, 2, 3, 1, 2, 1.

In the DataCamp window below, we put in the code to create a vector with nine 2s. We saved it in an R object called myvector1. Now you add the code to create a vector called myvector2 with the numbers 2, 1, 3, 3, 2, 3, 1, 2, 1. (HINT: use the c() function.) Run the code, then add some code to print out the two vectors just to make sure they ended up with the numbers you intended.

 require(tidyverse) require(mosaic)   #Here's how to create a vector with nine 2s myvector1 <- c(2,2,2,2,2,2,2,2,2) # Create a vector called myvector2 with the numbers 2,1,3,3,2,3,1,2,1. myvector2 <-   myvector2 <- c(2,1,3,3,2,3,1,2,1)   test_object("myvector2") 
Use the c() function
DataCamp: ch2-1

Now, let’s take the numbers in myvector2 and sort them in ascending order. We can use the sort() function for this.

sort(myvector2)

Now look at the numbers in myvector2 after we have sorted them. Suddenly it is easier to see a pattern in the variation: there are equal numbers of 1s, 2s, and 3s. Just sorting numbers makes it easier to see a pattern!

If you understand this example you have just mastered your first statistical technique! It may not look like much, but if you had a bigger data set (instead of nine numbers) you would quickly see the advantages of simply sorting them in order.

### Frequency Tables

We could also represent the same pattern in a frequency table using the command tally().

tally(myvector2)

L_Ch2_Starting_1

 require(mosaic) myvector1<-c(2,2,2,2,2,2,2,2,2)   # Now, just for fun, let's run the tally() function on myvector1, the one that had no variation   tally(x = myvector1)   test_object("myvector1") test_function("tally") 
Try tally(myvector1)
DataCamp: ch2-2

Believe it or not, you’ve now learned a second statistical technique—frequency tables (implemented in R as the tally() function)! As you learn more and more about statistics you will encounter lots and lots of techniques like this. Fundamentally, they are all variations on just a few core ideas. As you go, and as you build up your statistical power, we will help you keep it all in perspective.