Lesson 2: Qualitative Data
Lesson 2: Qualitative DataOverview
In this session we'll work with some qualitative (or categorical) data, using Chapter 2 of Essential R.
Objectives
- Differentiate between categorical (qualitative; factor) and continuous (quantitative; numeric) variables
- Create qualitative data using factor()
- make basic barcharts
- read in data using scan()
R
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
2.1 - Overview of data typesBefore 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
2.2 - Creating and Summarizing Qualitative DataIn this walk-through we'll create and summarize some qualitative data and begin to explore ways we can manipulate it.
2.3 - Visualising Qualitative Data
2.3 - Visualising Qualitative DataIn this screencast we'll look a bit more at manipulating qualitative data and we'll look at making simple barplots to visualize such data.
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.2.4 - Visualising Qualitative Data, cont.
2.4 - Visualising 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
2.5 - Converting from Factor to Numeric and CharacterIn 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
2.6 - Changing Factor Levels and Creating Ordered FactorsHere 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
2.7 - Hypothesis Testing with FactorsIn 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.