# PALS0046 candidate / Lab 02 - data types and missingness
# Run from the root folder containing data/ and scripts/.
pals <- read.csv("data/pals_synthetic.csv", stringsAsFactors = FALSE)
pals$condition <- factor(pals$condition,
                        levels = c("Control", "Training", "Mindfulness"))
pals$response <- factor(pals$response)
head(pals)
str(pals)
names(pals)
nrow(pals)
ncol(pals)
table(pals$condition)
pals$rt_ms
copy <- pals
copy$rt_ms[3] <- NA
sum(is.na(copy$rt_ms))
mean(copy$rt_ms)                # NA
mean(copy$rt_ms, na.rm = TRUE)  # 17 valid observations
# STUDENT TODO:
# 1. Explain why participant IDs are not measurements.
# 2. Create another safe copy, then make sleep_hours[2] missing.
# 3. Why is a missing value different from a measured zero?
# 4. What happens if you type pals$RT_ms (wrong case)?
