ggplot_regression_line
# Load necessary library
library(ggplot2)
# Create a sample dataset
data <- data.frame(x = c(1, 2, 3, 4, 5), y = c(2, 3, 4, 4.5, 5))
# Create a scatter plot with ggplot
ggplot(data, aes(x, y)) +
# Add points to the plot
geom_point() +
# Add a regression line
geom_smooth(method = "lm", se = FALSE) +
# Set plot title
ggtitle("Scatter Plot with Regression Line") +
# Set x-axis label
xlab("X-axis Label") +
# Set y-axis label
ylab("Y-axis Label") +
# Customize the theme
theme_minimal()