Weekly Challenge 2

Stevie Maizes

# Load Data 
library(readr)
data("cars")
head(cars)
##   speed dist
## 1     4    2
## 2     4   10
## 3     7    4
## 4     7   22
## 5     8   16
## 6     9   10
summary(cars)
##      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
mean_speed <- mean(cars$speed)
median_speed <- median(cars$speed)
sd_speed <- sd(cars$speed)

print(paste("The mean speed of cars is:", mean_speed))
## [1] "The mean speed of cars is: 15.4"
print(paste("The median speed of cars is:", median_speed))
## [1] "The median speed of cars is: 15"
print(paste("The standard deviation of speed is:", round(sd_speed, 2)))
## [1] "The standard deviation of speed is: 5.29"
speed_distance_correlation <- cor(cars$speed, cars$dist)
print(paste("The correlation between speed & distance of cars is:", round(speed_distance_correlation, 2)))
## [1] "The correlation between speed & distance of cars is: 0.81"