library(here) # paths relative to the project root
# Constants live in one place
train_frac <- 0.7
seed <- 204
raw <- read.csv(here("data", "raw", "survey.csv")) # not "/Users/me/Desktop/..."
clean <- subset(raw, !is.na(income))
message(nrow(raw) - nrow(clean), " rows dropped: missing income") # a decision, reported
set.seed(seed)
train_id <- sample(nrow(clean), size = floor(train_frac * nrow(clean)))
# Fail loudly: stop the render if an assumption breaks
stopifnot(
"Duplicated IDs after cleaning" = !anyDuplicated(clean$id),
"Train set is empty" = length(train_id) > 0
)