2 Qualitative Data
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:
- differentiate between categorical (qualitative; factor) and continuous (quantitative; numeric) variables,
- create qualitative data using
factor()
, - make basic barcharts, and
- 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.
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).
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.
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.
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.
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.
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.
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.