Cars dataset

This is my first R Markdown document. I have made use of the inbuilt cars dataset.

str(cars)
## 'data.frame':    50 obs. of  2 variables:
##  $ speed: num  4 4 7 7 8 9 10 10 10 11 ...
##  $ dist : num  2 10 4 22 16 10 18 26 34 17 ...
#As we can see, the cars dataset has 50 observations with 2 columns namely speed and distance. The 50 observations could be 50 instances of the same car or could be different cars as well, it is not known.
cars$acc<-cars$dist/(cars$speed^2) #adding a third column here, which is acceleration for the 50 instances.
str(cars)
## 'data.frame':    50 obs. of  3 variables:
##  $ speed: num  4 4 7 7 8 9 10 10 10 11 ...
##  $ dist : num  2 10 4 22 16 10 18 26 34 17 ...
##  $ acc  : num  0.125 0.625 0.0816 0.449 0.25 ...
head(cars)
##   speed dist        acc
## 1     4    2 0.12500000
## 2     4   10 0.62500000
## 3     7    4 0.08163265
## 4     7   22 0.44897959
## 5     8   16 0.25000000
## 6     9   10 0.12345679
library(psych)
describe(cars)
##       vars  n  mean    sd median trimmed   mad  min    max  range  skew
## speed    1 50 15.40  5.29  15.00   15.47  5.93 4.00  25.00  21.00 -0.11
## dist     2 50 42.98 25.77  36.00   40.88 23.72 2.00 120.00 118.00  0.76
## acc      3 50  0.19  0.10   0.16    0.17  0.05 0.08   0.62   0.55  2.23
##       kurtosis   se
## speed    -0.67 0.75
## dist      0.12 3.64
## acc       6.04 0.01
#The describe command here provides us with some descriptive statistics for the chosen dataset.

Plots

This is a simple visual idea of the variable speed, it shows how many times the car had a low speed of 0 to 5 mph and how many times it had a higher speed of 15 to 20 mph.

This is a simple boxplot of the distances travelled by the 50 cars or of the 50 instances travelled by the same car. There is one outlier towards the extreme right at around 90 miles. The median distance travelled is about 37 miles. The minimum distance travelled is about 5 miles and the maximum is 95 miles