- Using the Code bits below when can model our data using a Scatterplot.
- Once we do that we can then model the regression line for our Scatterplot.
ggplot(data, aes(x = Hours, y = Scores)) + geom_point() + labs(title = “Hours Studied vs. Exam Scores”, x = “Hours Studied”, y = “Exam Scores”) + theme_minimal()
model <- lm(Scores ~ Hours, data = data)
ggplot(data, aes(x = Hours, y = Scores)) + geom_point() + geom_smooth(method = “lm”, se = FALSE, color = “blue”) + labs(title = “Simple Linear Regression: Hours Studied vs. Exam Scores”, x = “Hours Studied”, y = “Exam Scores”) + theme_minimal()