R (tidyverse)+
library(tidyverse)
class <- tribble(
~subj_id, ~Name, ~Sex, ~Age, ~Height, ~Weight, ~score1, ~score2, ~score3, ~enrolled,
"S001", "Alfred", "M", 14, 69.0, 112.5, 85, 78, 92, TRUE,
"S002", "Alice", "F", 13, 56.5, 84.0, 91, 88, 95, TRUE,
"S003", "Barbara", "F", 13, 65.3, 98.0, 73, 80, 77, FALSE,
"S004", "Carol", "F", 14, 62.8, 102.5, 88, 85, 90, TRUE,
"S005", "Henry", "M", 14, 63.5, 102.5, 79, 82, 81, FALSE,
"S006", "James", "M", 12, 57.3, 83.0, 95, 93, 89, TRUE
)- We start by building an extended CLASS dataset using
tribble(). The extra columns are deliberate:subj_idgives us a character column besides Name and Sex,score1/score2/score3exercisenum_range(), andenrolledgives us a logical column forwhere(is.logical). - Every scenario below stores its result in a named dataset (
scenario01,scenario02, …). After running each line, type the scenario name on its own to print and confirm the column set matches the description before moving on.