Skip to content

Instantly share code, notes, and snippets.

@darioappsilon
Last active December 22, 2020 09:31
001_linear_regression
library(ggplot2)
# Generate synthetic data with a clear linear relationship
x <- seq(from = 1, to = 300)
y <- rnorm(n = 300, mean = x + 2, sd = 25)
# Convert to dataframe
simple_lr_data <- data.frame(x, y)
# Visualize as scatter plot
ggplot(data = simple_lr_data, aes(x = x, y = y)) +
geom_point(size = 3, color = "#0099f9") +
theme_classic() +
labs(
title = "Dataset for simple linear regression",
subtitle = "A clear linear relationship is visible"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment