# NOT RUN {
library(dplyr)
library(tibble)
# Convert rownames to column
mtcars <- mtcars %>%
rownames_to_column(var = "automobile")
# Fit lm() regression:
mpg_model <- lm(mpg ~ cyl, data = mtcars)
# Get information on all points in regression:
get_regression_points(mpg_model, ID = "automobile")
# Create training and test set based on mtcars:
training_set <- mtcars %>%
sample_frac(0.5)
test_set <- mtcars %>%
anti_join(training_set, by = "automobile")
# Fit model to training set:
mpg_model_train <- lm(mpg ~ cyl, data = training_set)
# Make predictions on test set:
get_regression_points(mpg_model_train, newdata = test_set, ID = "automobile")
# }
Run the code above in your browser using DataLab