This document covers the foundations of quantitative data analysis. You will work with a real dataset in R and move through six sections, step by step:
How it works. Each section starts with a short explanation and some R code. Copy the code into R, run it, and answer the questions at the end of the section. When all answers in a section are correct, the next section opens. If an answer is wrong, you will get a hint that sends you back to the part you should review. You can try as many times as you need.
Answer rules
28.55).Solutions are locked. When you receive the password, enter it here to open every section and see all solutions.
In this document we use the sat.act dataset from the
psych package. It contains self-reported test scores of
700 people on the ACT and the SAT, together with their gender, education
level and age.
| Variable | Description |
|---|---|
gender |
1 = male, 2 = female |
education |
Self-reported education, coded 0 to 5 (higher codes mean more education) |
age |
Age in years |
ACT |
ACT composite score |
SATV |
SAT Verbal score |
SATQ |
SAT Quantitative score |
Step 1. Install the psych package (only once) and load it.
Step 2. Load the data and make a working copy called
dat.
Step 3. Prepare the categorical variables.
gender becomes a factor with labels, and
education becomes an ordered factor.
dat$gender <- factor(dat$gender, levels = c(1, 2), labels = c("male", "female"))
dat$education <- factor(dat$education, levels = 0:5, ordered = TRUE)
str(dat)Step 4. Check the size of the data and the missing values.
dat?SATQ have?SATQ?dat (that is, dat[10, ])?