2  Qualitative Data

Data
R Code
Qualitative data
Factor levels
Hypothesis testing

Overview

In this lesson, we’ll work with some qualitative (or categorical) data, using Chapter 2 of Essential R Course Notes.

Objectives

Upon completion of this lesson, you should be able to:


  1. differentiate between categorical (qualitative; factor) and continuous (quantitative; numeric) variables,
  2. create qualitative data using factor(),
  3. make basic barcharts, and
  4. read in data using scan().

Data and R Code Files

The R code file and data files for this lesson can be found on the Essential R - Notes on learning R page.

R logo

2.1 Overview of data types

Before we delve into qualitative (categorical/factor) data, we’ll review the basic data types in R and see how to tell which type of data R thinks you have (mismatches between your understanding of your data and R’s understanding of your data are a common cause of errors).

Video - STAT 484 Lesson: 2.1

2.2 Creating and Summarizing Qualitative Data

In this walkthrough, we’ll create and summarize some qualitative data and begin to explore ways we can manipulate it.

Video - STAT 484 Lesson: 2.2

2.3 Visualizing Qualitative Data

In this screencast, we’ll look a bit more at manipulating qualitative data and we’ll look at making simple barplots to visualize such data.

Note! the flexibility shown by R in parsing arguemnts to functions - barplot(height=tab) can be abbreviated as barplot(hei=tab) or just barplot(tab) - argument names can be abbreviated or omitted if omitted arguments will be infered from placement.

Video - STAT 484 Lesson: 2.3

2.4 Visualizing Qualitative Data, cont.

Here we’ll continue our exploration of visualizing qualitative data with pie charts (though pie charts are well known to be a poor way to understand data, some folks still demand them).

More importantly, we’ll see how to use the function levels() to retrieve or change the levels for a factor.

Video - STAT 484 Lesson: 2.4

2.5 Converting from Factor to Numeric and Character

In this screencast, we’ll explore how factors are stored in R, and the implications this has for how we might convert data between factor and numeric forms.

Video - STAT 484 Lesson: 2.5

2.6 Changing Factor Levels and Creating Ordered Factors

Here we’ll look at changing the levels for factors, changing the number of levels for factors, and creating ordered factors.

Video - STAT 484 Lesson: 2.6

2.7 Hypothesis Testing with Factors

In this screencast, we’ll demonstrate hypothesis testing with factors using the proportion test. We’ll also review what we learned about loops in the last chapter and with a simulation approximation of the proportion test.

Video - STAT 484 Lesson: 2.7