Table 1.3 displays rows 1, 2, 3, and 50 of a data set concerning 50 emails received during early 2012. These observations will be referred to as the email50 data set, and they are a random sample from a larger data set that we will see in Section 1.7.
Each row in the table represents a single email or case.33A case is also sometimes called a unit of observation or an observational unit. The columns represent characteristics, called variables, for each of the emails. For example, the first row represents email 1, which is a not spam, contains 21,705 characters, 551 line breaks, is written in HTML format, and contains only small numbers.
In practice, it is especially important to ask clarifying questions to ensure important aspects of the data are understood. For instance, it is always important to be sure we know what each variable means and the units of measurement. Descriptions of all five email variables are given in Table 1.4.
spam | num_ char | line_ breaks | format | number | |
---|---|---|---|---|---|
1 | no | 21,705 | 551 | html | small |
2 | no | 7,011 | 183 | html | big |
3 | yes | 631 | 28 | text | none |
50 | no | 15,829 | 242 | html | small |
variable | description |
---|---|
spam | Specifies whether the message was spam |
num_ char | The number of characters in the email |
line_ breaks | The number of line breaks in the email (not including text wrapping) |
format | Indicates if the email contained special formatting, such as bolding, tables, or links, which would indicate the message is in HTML format |
number | Indicates whether the email contained no number, a small number (under 1 million), or a large number |
The data in Table 1.3 represent a data matrix, which is a common way to organize data. Each row of a data matrix corresponds to a unique case, and each column corresponds to a variable. A data matrix for the stroke study in Section 1.1 is shown in Table 1.1, where the cases were patients and there were three variables recorded for each patient.
Data matrices are a convenient way to record and store data. If another individual or case is added to the data set, an additional row can be easily added. Similarly, another column can be added for a new variable.
We consider a publicly available data set that summarizes information about the 3,143 counties in the United States, and we call this the county data set. This data set includes information about each county: its name, the state where it resides, its population in 2000 and 2010, per capita federal spending, poverty rate, and five additional characteristics. How might these data be organized in a data matrix?
Answer. Each county may be viewed as a case, and there are eleven pieces of information recorded for each case. A table with 3,143 rows and 11 columns could hold these data, where each row represents a county and each column represents a particular piece of information. Seven rows of the county data set are shown in Table 1.5, and the variables are summarized in Table 1.6. These data were collected from the US Census website.44http://quickfacts.census.gov/qfd/index.html
name | state | pop2000 | pop2010 | fed_ spend | poverty | homeownership | multiunit | income | med_ income | smoking_ ban | |
1 | Autauga | AL | 43671 | 54571 | 6.068 | 10.6 | 77.5 | 7.2 | 24568 | 53255 | none |
2 | Baldwin | AL | 140415 | 182265 | 6.140 | 12.2 | 76.7 | 22.6 | 26469 | 50147 | none |
3 | Barbour | AL | 29038 | 27457 | 8.752 | 25.0 | 68.0 | 11.1 | 15875 | 33219 | none |
4 | Bibb | AL | 20826 | 22915 | 7.122 | 12.6 | 82.9 | 6.6 | 19918 | 41770 | none |
5 | Blount | AL | 51024 | 57322 | 5.131 | 13.4 | 82.0 | 3.7 | 21070 | 45549 | none |
3142 | Washakie | WY | 8289 | 8533 | 8.714 | 5.6 | 70.9 | 10.0 | 28557 | 48379 | none |
3143 | Weston | WY | 6644 | 7208 | 6.695 | 7.9 | 77.9 | 6.5 | 28463 | 53853 | none |
variable | description |
---|---|
name | County name |
state | State where the county resides (also including the District of Columbia) |
pop2000 | Population in 2000 |
pop2010 | Population in 2010 |
fed_ spend | Federal spending per capita |
poverty | Percent of the population in poverty |
homeownership | Percent of the population that lives in their own home or lives with the owner (e.g. children living with parents who own the home) |
multiunit | Percent of living units that are in multi-unit structures (e.g. apartments) |
income | Income per capita |
med_ income | Median household income for the county, where a household’s income equals the total income of its occupants who are 15 years or older |
smoking_ ban | Type of county-wide smoking ban in place at the end of 2011, which takes one of three values: none, partial, or comprehensive, where a comprehensive ban means smoking was not permitted in restaurants, bars, or workplaces, and partial means smoking was banned in at least one of those three locations |