# Say new_data has 5 rows
new_data <- mtcars[1:5, ]
# And somehow you generate predictions
# for those 5 rows
pred_vec <- 1:5
# Then you use `spruce_numeric()` to clean
# up these numeric predictions
pred <- spruce_numeric(pred_vec)
pred
# Use this check to ensure that
# the number of rows or pred match new_data
check_prediction_size(pred, new_data)
# An informative error message is thrown
# if the rows are different
try(validate_prediction_size(spruce_numeric(1:4), new_data))
Run the code above in your browser using DataLab