This project is my submission for the "R You Ready for Regression" AI/ML challenge. It demonstrates how to perform simple linear regression using R on two classic built-in datasets: mtcars and iris.
regression_analysis.Rβ R script for data analysis and plottingplot_mtcars.pngβ Regression of MPG vs Weight (mtcars)plot_iris.pngβ Regression of Petal Length vs Petal Width (iris)
Model: mpg ~ wt
- Predicts Miles per Gallon (mpg) from Weight (wt)
- Shows a negative relationship: as weight increases, MPG decreases
Sample Output:
Call: lm(formula = mpg ~ wt, data = mtcars)
Coefficients: (Intercept) wt 37.285 -5.344
Model: Petal.Length ~ Petal.Width
- Predicts Petal Length based on Petal Width
- Strong positive correlation: wider petals tend to be longer
Sample Output:
Call: lm(formula = Petal.Length ~ Petal.Width, data = iris)
Coefficients: (Intercept) Petal.Width 1.084 2.229
Make sure R is installed on your system. Then run the following command in your terminal or RStudio:
Rscript regression_analysis.R
This will:
- Print model summaries in the console
- Save the plots as:
plot_mtcars.pngplot_iris.png
ggplot2β for creating regression plots

