The cars
dataset is a built-in dataset in R that
contains data about the speed of cars and the corresponding stopping
distances. This dataset consists of 50 observations with two variables:
Speed and Distance Summary Statistics speed dist
Min. : 4.0 Min. : 2.00
1st Qu.:12.0 1st Qu.: 26.00
Median :15.0 Median : 36.00
Mean :15.4 Mean : 42.98
3rd Qu.:19.0 3rd Qu.: 56.00
Max. :25.0 Max. :120.00
From the scatter plot, we can see that there is a positive relationship between the speed of the car and the stopping distance. As the speed of the car increases, the stopping distance also increases.
library(ggplot2)
ggplot(cars, aes(x = speed, y = dist)) +
geom_point(color = "blue", size = 3) +
labs(title = "Speed vs Stopping Distance",
x = "Speed (mph)",
y = "Stopping Distance (ft)") +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5)) # Center the title