evoalgs-r-practise/intro/testfile-1.R

20 lines
346 B
R
Raw Normal View History

2024-04-30 08:03:37 +00:00
# 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")