Displaying Categorical Data: Forming Connections

Larks or Owls?

A student napping on a desk in a classroom

In a 2012 sleep study[1], a sample of [latex]253[/latex] college students completed skills tests to measure cognitive function, completed surveys that ask many questions about attitudes and habits, and kept sleep diaries to record time and quality of sleep over a two-week period. The relationship between sleep and academic performance was evaluated.  During this activity, you’ll use the Sleep Study data set to see that there are multiple ways to display categorical data.

In the sleep study, students were asked if they identified as Larks, Owls, or Neither. A Lark is a morning person, an Owl is a night person, and Neither is a person who is neither a morning or night person. Their responses were recorded in a variable named Chronotype.

video placement

[Intro: “In this activity, we’ll use technology to create graphical displays of a categorical variable. You should be familiar with picking out the categorical data from a data set and making a frequency table. Don’t worry, we’ll walk through the use of the analysis tool step by step. The key piece to take away from this activity will be understanding that there are multiple ways to display categorical data. You’ll be able to create freqency tables, bar graphs, and pie charts using technology and then use data distributions displayed in those tables and graphs to answer questions about a variable. Before we get started, think about your own chronotype; are you an Owl, a Lark, or neither? How about the others who go to your school? Do you think college students tend to be one or the other?”]

Categorical Variables

Before you look at the data set, think for a moment about the assumptions you already hold about college students, then answer the first question below.

question 1

The following [latex]10[/latex] variables are included in the sleep study data set. The variable names are presented in italics followed by a brief description. Recall that this is called a data dictionary.

  • Chronotype: Lark, owl, or neither; a lark is a morning person, an owl is a night person, and neither is neither a morning nor a night person
  • ClassYear: 1, 2, 3, 4; 1 = freshman, 2 = sophomore, 3 = junior, 4 = senior
  • NumEarlyClass: Number of classes per week taken before 9 am
  • EarlyClass: 0, 1; 0 = is not taking any early classes and 1 = is taking at least one early class
  • GPA: Grade point average (0–4 scale)
  • ClassesMissed: Number of classes missed in a semester
  • PoorSleepQuality: Measure of sleep quality (higher values indicate poorer sleep)
  • Stress: Coded stress score, normal or high
  • AlcoholUse: Self-reported alcohol use—abstain, light, moderate, heavy
  • Drinks: Number of alcoholic drinks per week

question 2

question 3

Pie Charts

Let’s use technology to create a pie chart that visualizes the distribution of Chronotype for all [latex]253[/latex] students in the study.

video placement

[Guiding: “This will be your first time using this tool in an activity. Let’s see how it should look together. [display the tool, going through the steps below to create a pie chart.] ]

Go to the Describing and Exploring Categorical Data tool at https://dcmathpathways.shinyapps.io/EDA_categorical/

Step 1) Select the One Categorical Variable tab.

Step 2) Locate the dropdown under Enter Data and select From Textbook.

Step 3) Click on the dropdown menu for Data Set and choose Sleep Study – Lark vs. Owl.

Step 4) Scroll down to Additional Plots and select the Pie Chart option.  The pie chart will appear below the bar graph.

question 4

Consider a hypothetical class of [latex]42[/latex] students, each of whom answered the question, “are you a lark, an owl, or neither?” Let’s suppose that [latex]12[/latex] responded that they were larks, [latex]20[/latex] that they were owls, and [latex]10[/latex] said they were neither a lark nor an owl.

video placement

[Guiding: “[First demonstrate using fake information for a few observations (say, n = 5 or 6, for simplicity)to create a frequency table, then display the tool, going through the steps below to enter the data from the frequency table. Also show that students may, alternatively, enter the data as “observations” by making the appropriate selection under “Enter Data” and then entering observations as “lark lark owl etc…] ]

Use the Describing and Exploring Categorical Data tool to create a pie graph for these data. Follow these steps:

Step 1) Select the One Categorical Variable tab.

Step 2) Locate the dropdown under Enter Data and select Frequency Table.

Step 3) Enter “3” for Number of Categories.

Step 4) In the box under Name of Variable, type Chronotype.

Step 5) Enter the labels for the 3 chronotypes and their respective numbers observed in the hypothetical class.

Step 6) Scroll down to locate Additional Plots and select Pie Chart.

question 5

question 6

Bar Graphs

Let’s use a bar graph to examine another of the variables from the sleep study Alcohol use.

video placement

[Guiding:  [display the tool, going through the steps below to create a bar graph.] ]

In the Describing and Exploring Categorical Data tool, follow these steps:

Step 1) Select the One Categorical Variable tab.

Step 2) Under Enter Data choose From Textbook.

Step 3) Under Data Set, select Sleep Study – Alcohol Use.

Step 4) Under Options, check the Customize Order box to change the order of the bars to provide more meaning.

Step 5) Click in the box under Choose Order of Categories and the order should be abstain, light, moderate, heavy.

Step 6) Under Additional Plots select None.

question 7

question 8

Research Questions

Now you try the tool on our own to create a graph. Use the data set “Sleep Study – Class Year” to create a bar graph to show the class years of the college students in the study. Make sure they are in the appropriate order. Look back to the steps above for guidance as needed.

question 9

question 10

video placement

[Wrap-up: “What did you discover? Did you find evidence for underage drinking? We saw that there were many sophomores involved in the study and we saw that many students responded that they drank “moderately.” Do you feel the combination of these two variables points to underage drinking being present at the survey school? There are other good questions to ask about this data, as well. Do you think there would be a relationship between alcohol and academic performance? What about alcohol and sleep?  Before we move on to the next section, let’s recap the objectives for this activity. [voice over the list at the top of the page, or move through the page using jump links] You’ve identified the categorical variables in the data set and used technology to create frequency tables, bar graphs, and pie charts, then used those displays to answer research questions about the data. We’ll return to this study in future sections of the course to investigate other questions: would owls drink more than larks? Are different class levels more likely to be larks or owls? These are all good questions. Can you think of others?”]


  1.  SleepStudy: Sleep Study. (2019, May 2). rdrr.oi. Retrieved from https://rdrr.io/cran/Lock5withR/man/SleepStudy.html