# Load necessary package library(ggplot2) # Create some data df <- data.frame( x = 1:100, y = 2 * (1:100) + rnorm(100) ) # Perform linear regression model <- lm(y ~ x, data = df) # Summary of the model summary(model) # Plot the data and the model ggplot(df, aes(x = x, y = y)) + geom_point() + geom_smooth(method = "lm", col = "red")