Fit the Model

model <- lm(
  wages ~ gender + race + union + education + experience,
  data = jeksterslabRdatarepo::wages
)
yhat <- as.vector(predict(model))
epsilonhat <- as.vector(residuals(model))
tepsilonhat <- as.vector(rstudent(model))
h <- as.vector(hatvalues(model))

Plot the Residuals

.residual.plot(
  yhat = yhat,
  tepsilonhat = tepsilonhat,
  epsilonhat = epsilonhat,
  h = h
)
expect_error(
  object = .residual.plot(
    yhat = yhat,
    tepsilonhat = tepsilonhat,
    epsilonhat = epsilonhat,
    h = h
  ),
  regexp = NA
)